• 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: nsdocument/nsapp delegate question
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: nsdocument/nsapp delegate question


  • Subject: Re: nsdocument/nsapp delegate question
  • From: Alex Rice <email@hidden>
  • Date: Tue, 2 Oct 2001 01:18:59 -0600

On Monday, October 1, 2001, at 11:45 PM, John C. Randolph wrote:
Where I'm stuck is that I need find out in applicationWillFinishLaunching: whether or not the app was launched via a document or via the app. But, application:openFile: is not sent until after applicationWillFinishLaunching: and by the time applicationDidFinishLaunching: is sent, there is already an untitled document opened automatically. How else can I check how the app was launched via a document?

I think you can get the behaviour you describe just by implementing -applicationShouldOpenUntitledFile: in your app delegate. That shouldn't get called until the app is finished launching.

Thanks- at first I didn't think that -applicationShouldOpenUntitledFile: was the answer, however with some judicious setting of flags to see if the app is finishing launching, and if another document has been loaded already, I've got it working:

- (BOOL)applicationShouldOpenUntitledFile:(NSApplication *)sender
{
if(! launching) // don't interfere w/ normal use of untitled files
return YES;
if((! hasOpenedDocument) &&
(! [[NSUserDefaults standardUserDefaults]
boolForKey:@"loadPreviousDocumentOnStartup"]))
{
return YES;
}
return NO;
}

This works, but my cocoa sense expected to find a method like [NSApp wasLaunchedByDocumentIcon] or somesuch.

Thanks,

Alex Rice <email@hidden>
Mindlube Software
http://www.mindlube.com/


References: 
 >Re: nsdocument/nsapp delegate question (From: "John C. Randolph" <email@hidden>)

  • Prev by Date: White Cursor
  • Next by Date: NSUnarchiver question
  • Previous by thread: Re: nsdocument/nsapp delegate question
  • Next by thread: White Cursor
  • Index(es):
    • Date
    • Thread