Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cocoa app without a MainMenu.xib

For iOS (Cocoa Touch), it's possible to go to your main.m and replace the fourth argument in UIApplicationMain(int argc, char *argv[], nil, nil) with the class name of your app's delegate, which would then construct the views as needed. However, Cocoa (Mac) projects have the following in main.m:

    return NSApplicationMain(argc, (const char **)argv);

So the question is basically: how do you hand over an app's delegate to Cocoa apps without a MainMenu.xib?

like image 530
tux91 Avatar asked Aug 04 '11 17:08

tux91


1 Answers

You can use setDelegate method of NSApplication instance. Here is a sample:

AppDelegate * delegate = [[AppDelegate alloc] init];
[[NSApplication sharedApplication] setDelegate:delegate];
[NSApp run];

As for return value you can use EXIT_SUCCESS

like image 172
VenoMKO Avatar answered Nov 09 '22 10:11

VenoMKO