Forum Navigation
You need to log in to create posts and topics.

Crash when window is closed but OK when on normal Quit.

Posted by: fblistserve <fblistserve@...>

My main app delegate contains:

-(void)doQuitHouseKeeping
{
    // save selected tabview pane in preferences
    NSUserDefaults *ud = [NSUserDefaults standardUserDefaults];
    [ud setInteger: [self getPaneLastUsed] forKey:kPaneLastUsedKey];// <<<<<<<<<<<< crashes here on window close
    [ud synchronize];
}
// app delegate callbacks
-(BOOL)applicationShouldTerminateAfterLastWindowClosed:(NSApplication*)theApplication
{
    return YES;
}
- (void)applicationWillTerminate:(NSNotification *)aNotif
{
    [self doQuitHouseKeeping];
}
On a window close the [self getPaneLastUsed] crashes. If the app is Quit no crash and all works. AFAIK, umy use of these two delegate callbacks is correct. It seems the tab object is gone at the point doQuitHouseKeeping executes which explains the crash trying to call a method on it. Suggestions welcome for what delegates to use here. My fallback solution is just write the pref each time the user changes tabs but I don’t like it.

Brian S.


To unsubscribe, e-mail: fbcocoa-unsubscribe@welovegod.org For additional commands, e-mail: fbcocoa-help@freegroups.net