views:

196

answers:

2

Is it possible to instalize an NSRunLoop with needing to load any Nib files ie. without needing to call: NSApplicationMain();

Thanks

+2  A: 

Yes you can write your own main method and run NSRunLoop without returning from NSApplicationMain.

Have a look at this link, this guy is using NSRunLoop in his main method, he is not loading nib files though, but it should get you going with NSRunloops

Link

raziiq
+2  A: 

The solution is to invoke NSApplication manually. Create your app delegate first than replace the NSApplicationMain() call in main.m with the following:

AppDelegate * delegate = [[AppDelegate alloc] init];

NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];

NSApplication * application = [NSApplication sharedApplication];
[application setDelegate:delegate];
[NSApp run];

[pool drain];

[delegate release];

The delegate will be invoked when ready, without needing a nib

- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
Ben Reeves