Objective C: App freezes when using a timer
- by Chris
It took me hours to figure out how to implement a timer into my program, but when it runs, the app doesn't load completely as it did before the timer. 
In my main.m:
int main (int argc, const char * argv[]) {  
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
 OutLauncher *theLauncher = [[OutLauncher alloc] init];
NSTimer *theTimer = [theLauncher getTimer];
[theTimer retain];
[[NSRunLoop currentRunLoop] addTimer: theTimer forMode: NSDefaultRunLoopMode];
 [[NSRunLoop currentRunLoop] run];
 [pool release];
 return 0;  
 }
The file OutLauncher is being imported into that, which looks like this:
- (void)doStuff {  
NSLog( @"Doing Stuff");  
}
 - (NSTimer *)getTimer{  
 NSTimer *theTimer;
 theTimer = [NSTimer scheduledTimerWithTimeInterval:1.0 target:self selector: @selector(doStuff) userInfo:nil repeats:YES];
 return [theTimer autorelease];
}
The timer works, the console updates every second with the phrase "doing stuff" but the rest of the program just won't load. It will if I comment out the code I added to int main though