某些情况下使用messagebox 阻塞程序,进而附加进程调试是比较舒服的。
mac 无法使用 <windows.h>,因此无法使用windows 下的messagebox,因此采用cocoa的能力封装messagebox来满足自己的需要
//messagebox.h
#ifndef CEF_MESSAGE_BOX_H_
#define CEF_MESSAGE_BOX_H_
#include <string>
#pragma once
namespace client {
void messagebox(std::string);
}
#endif // CEF_MESSAGE_BOX_H_
//messagebox.mm
#include "messagebox.h"
#import <Cocoa/Cocoa.h>
namespace client {
void messagebox(std::string str){
NSAlert *alert = [[NSAlert alloc] init];
[alert addButtonWithTitle:@"OK"];
[alert addButtonWithTitle:@"Cancel"];
[alert setMessageText:@(str.c_str())];
[alert runModal];
}
}