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 (Cocoa-dev@lists.apple.com)

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

This email sent to arch...@mail-archive.com

Reply via email to