> On Mar 5, 2016, at 4:36 AM, Daryle Walker <[email protected]> wrote:
>
> Default project Xcode 7 with OS X Cocoa app, with Storyboards but without
> Core Data nor Documents. Somewhere I messed up and State Restoration stopped
> working correctly. It somehow thinks when quit happens and any open windows
> get automatically closed that those windows were user-closed instead and
> therefore not restored. I was having problems before with windows hanging
> around in the wrong position, so I must have fried a setting somewhere or
> made some other bad assumption.
Did you implement the applicationShouldTerminateAfterLastWindowClosed(_:)
delegate method, returning true? If you do that, and if the user (or some other
cause, such as an AppleScript script) does close the last window, then Cocoa's
state restoration mechanism (interface persistence, or the "Resume" feature)
does not save the window's last state (position, size, etc.) because the window
was no longer open when termination time arrives.
I work around this by not implementing that delegate method, and instead
implement the windowShouldClose(_:) delegate method in my main window
controller like this:
func windowShouldClose(sender: AnyObject) -> Bool {
if window != nil {
NSApplication.sharedApplication().performSelector("terminate:",
withObject: self, afterDelay: 0.0)
return false // keep main window open until "terminate:" selector
is performed in next iteration of run loop
}
return true
}
--
Bill Cheeseman - [email protected]
_______________________________________________
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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com
This email sent to [email protected]