• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: debugging hard-to-locate error in NSApplication delegate
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Follow-Ups:
    • Re: debugging hard-to-locate error in NSApplication delegate
      • From: "Michael Ash" <email@hidden>
    • Re: debugging hard-to-locate error in NSApplication delegate
      • From: Keary Suska <email@hidden>
    • [SOLVED] Re: debugging hard-to-locate error in NSApplication delegate
      • From: Greg Beaver <email@hidden>
References: 
 >debugging hard-to-locate error in NSApplication delegate (From: Greg Beaver <email@hidden>)

  • Prev by Date: Re: Disabled button looks like enabled
  • Next by Date: Re: Disabled button looks like enabled
  • Previous by thread: RE: debugging hard-to-locate error in NSApplication delegate
  • Next by thread: [SOLVED] Re: debugging hard-to-locate error in NSApplication delegate
  • Index(es):
    • Date
    • Thread