• 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 last document loading
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSDocument last document loading


  • Subject: Re: NSDocument last document loading
  • From: Todd Heberlein <email@hidden>
  • Date: Mon, 02 Jul 2012 18:13:46 -0700

On Jul 2, 2012, at 2:13 PM, Kyle Sluder wrote:

> Oops, I should've said "call -setRestorable:", not -setRestorationClass:. Going with -setRestorable: is the most direct way to define your explicit intent.


Below is what I added to my Document class (which works with some interesting caveats below);

- (void)windowControllerDidLoadNib:(NSWindowController *)aController
{
    [super windowControllerDidLoadNib:aController];
    [[aController window] setRestorable:NO];
}


Interestingly, it has two different behaviors depending on whether I launch the application via Xcode or double clicking it in the Finder. Double clicking it in the finder does what I expect -- it launches a single empty document window. But when I run it from Xcode, no document window appears *until* I click on the icon in the dock. The application is the front running application (at least its menus are displayed).

Since I was initially only running it from Xcode (and no initial document window was showing up), I tried working around this by creating an application delegate and adding this method:

- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
{
    NSDocumentController *myDocController;
    NSError *myError;

    myDocController = [NSDocumentController sharedDocumentController];
    [myDocController openUntitledDocumentAndDisplay:YES error:&myError];
}

Which worked fine in Xcode (got a single initial blank document window at start), but when I launched the application from the finder, I got *two* windows.

In the end, I got rid of the application delegate so the program behaves correctly when launching it from the Finder.

Todd



_______________________________________________

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

References: 
 >Re: NSDocument last document loading (From: Lee Ann Rucker <email@hidden>)
 >Re: NSDocument last document loading (From: Kyle Sluder <email@hidden>)
 >Re: NSDocument last document loading (From: Kyle Sluder <email@hidden>)

  • Prev by Date: Re: NSInteger vs int vs int32_t
  • Next by Date: Re: NSDocument last document loading
  • Previous by thread: Re: NSDocument last document loading
  • Next by thread: Re: NSDocument last document loading
  • Index(es):
    • Date
    • Thread