On Wed, Sep 15, 2010 at 7:11 PM, Jerry Krinock <[email protected]> wrote:
> Anything that I want to happen before a document opens, in case the app is 
> launched by doubleclicking a document.

I think the right pattern to use here would be to set a flag in
-applicationDidFinishLaunching: or some later point. Until that flag
is set, return NO from -applicationShouldOpenUntitledFile:.

@interface MyAppDelegate : NSObject <NSApplicationDelegate> {
  BOOL _shouldOpenUntitled;
}

@end

@implementation MyAppDelegate

- (BOOL)applicationShouldOpenUntitledFile:(NSApplication *)myApp; {
  return _shouldOpenUntitled;
}

- (void)applicationDidFinishLaunching:(NSNotification *)aNote; {
  if (DoStuffBeforeFirstDocument() == YES) {
    _shouldOpenUntitled = YES;
    [[NSDocumentController sharedDocumentController] newDocument:nil];
  }
}

@end

> Is it correct to say that one should not do "GUI Things" or "AppKit Stuff" in 
> -applicationWillFinishLaunching: ?

I would say that is a safe rule to live by.

--Kyle Sluder
_______________________________________________

Cocoa-dev mailing list ([email protected])

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [email protected]

Reply via email to