Re: debugging hard-to-locate error in NSApplication delegate
Re: debugging hard-to-locate error in NSApplication delegate
- Subject: Re: debugging hard-to-locate error in NSApplication delegate
- From: Quincey Morris <email@hidden>
- Date: Mon, 12 Jan 2009 10:41:30 -0800
On Jan 12, 2009, at 08:11, Greg Beaver wrote:
Does anyone have working code that shows an application delegate in a
core data document-based app? I'm trying to intercept
applicationShouldOpenUntitledFile: in order to open the last-saved
document. I have code that works, but it causes this error:
*** -[NSCFArray insertObject:atIndex:]: attempt to insert nil
some time between the setting of the delegate, which I did by
inserting
this object into the nib and setting the delegate programmatically.
linking from IB did not properly set the delegate (init and
applicationDidFinishLaunching: were called, but
applicationShouldOpenUntitledFile: was never called):
@implementation GreenwoodAppDelegate
- (void) init
{
[super init];
applicationHasStarted = NO;
if (![[NSApplication sharedApplication] delegate]) {
[[NSApplication sharedApplication] setDelegate:self];
}
}
This isn't going to work because your app delegate object is in your
NIB file and is (re)created at startup by unarchiving. Therefore,
'initWithCoder' will be called instead or 'init'.
I think you'd be better off setting your application's delegate outlet
to the app delegate object in your main NIB file after all, and then
trying to work out why applicationShouldOpenUntitledFile: isn't
behaving as expected.
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden