I am having a problem with gui / threading when developing a cocoa user interface. The application is designed as follows:
Main thread (# 1): parses arguments, loads plugins, etc.
Gui thread (#?): Launches gui, processes events, etc. His stream is gui.
The cocoa structure is unsafe, but provides one rule, the GUI should work in the main thread. For verification, a statement is used. To try to get around this, I implemented the launch method itself (code below) - http://cocoawithlove.com/2009/01/demystifying-nsapplication-by.html - manual. But I'm missing something. The window opens, but remains empty (completely white). Although, if I make a call in the main thread, it works fine.
So basically I need to find out what is missing.
- (void)run { NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; [self finishLaunching]; shouldKeepRunning = YES; do { [pool release]; pool = [[NSAutoreleasePool alloc] init]; NSEvent *event = [self nextEventMatchingMask:NSAnyEventMask untilDate:[NSDate distantFuture] inMode:NSDefaultRunLoopMode dequeue:YES]; [self sendEvent:event]; [self updateWindows]; } while (shouldKeepRunning); [pool release]; } - (void)terminate:(id)sender { shouldKeepRunning = NO; }
source share