I am a iOS developer and going to develop an OS X application.
However they are so different from each other.
I want to add a splash screen at the application startup.
- (void) applicationDidFinishLaunching:(NSNotification *)aNotification {
// Hide main window
[self.window orderOut:nil];
SplashWindowController *splashWindowController = [[SplashWindowController alloc] initWithWindowNibName:@"SplashWindowController"];
[NSApp runModalForWindow:splashWindowController.window];
[splashWindowController release];
// Show main window
...
And here is “SplashWindowController.m”
- (void)windowDidLoad {
[super windowDidLoad];
[NSTimer scheduledTimerWithTimeInterval:2.0 target:self selector:@selector(hideSplash) userInfo:nil repeats:NO];
}
- (void)hideSplash {
[NSApp endSheet:self.window];
[self.window orderOut:nil];
}
I can see the appeared splash, but hideSplash function is never called.
What’s the reason?
I’m wondering that you don’t get an error, but this line has a typo:
it should be
On the other hand, you could try this one:
I’m not sure if the [NSTimer…] is destroyed too soon… Assigning it to an instance should be fine. Also afaik the run loop is interrupted so you could try adding the timer to the main run loop.