You can display an AlertPanel even if you have a strictly command line app. In the example below it shows a NSPanel called from pure C.
id app = NULL;
id pool = (id)objc_getClass("NSAutoreleasePool");
if (!pool)
{
return -1;
}
pool = objc_msgSend(pool, sel_registerName("alloc"));
if (!pool)
{
return -1;
}
pool = objc_msgSend(pool, sel_registerName("init"));
app = objc_msgSend((id)objc_getClass("NSApplication"),
sel_registerName("sharedApplication"));
NSRunAlertPanel(CFSTR("Test"),
CFSTR("Your App is running!"),
CFSTR("Ok"), NULL, NULL);
objc_msgSend(pool, sel_registerName("release"));
id app = NULL;
id pool = (id)objc_getClass("NSAutoreleasePool");
if (!pool)
{
return -1;
}
pool = objc_msgSend(pool, sel_registerName("alloc"));
if (!pool)
{
return -1;
}
pool = objc_msgSend(pool, sel_registerName("init"));
app = objc_msgSend((id)objc_getClass("NSApplication"),
sel_registerName("sharedApplication"));
NSRunAlertPanel(CFSTR("Test"),
CFSTR("Your App is running!"),
CFSTR("Ok"), NULL, NULL);
objc_msgSend(pool, sel_registerName("release"));
No comments:
Post a Comment