Re: Lion's 'restore windows' vs. app with initial 'login'
Re: Lion's 'restore windows' vs. app with initial 'login'
- Subject: Re: Lion's 'restore windows' vs. app with initial 'login'
- From: Quincey Morris <email@hidden>
- Date: Tue, 07 Feb 2012 11:09:16 -0800
On Feb 7, 2012, at 09:27 , Eric Slosser wrote:
> I've got an app that has a login step at the beginning. Until the user has logged on, it's inappropriate to display the documents that were open when the last user quit. Lion's 'restore windows' feature happens while my login dialog is still open. I've looked at the slides for the WWDC 2011 session "Resume and Automatic Termination in Lion" and they don't address the concept of an app with a startup gateway like a login dialog.
>
> Through experimentation, I found that 'resume' is happening through calls to -[MyDocController openDocumentWithContentsOfURL:display:error]. I plan to put a check for login there. If the user hasn't logged in, I'll save the URLs, return NULL, and process them later. When I process them, I can also filter out URLs that 'belong' to someone other than the current logged in user.
'openDocumentWithContentsOfURL:display:error:' is deprecated in Lion, so it's surprising that it's being called instead of 'openDocumentWithContentsOfURL:display:completionHandler:', and maybe you can't rely on it being called in future updates.
An alternative approach might be to override 'restoreDocumentWindowWithIdentifier:state:completionHandler:' (not documented anywhere except the NSWindowRestoration.h header file, but discussed in the WWDC video). I believe you're allowed to defer the calling of the completion handler, so could either ask for the login in this method, or add the parameters to a queue and deal with them after a login.
It's not clear whether deferring one completion handler also defers invocation of the above method for additional windows, or if you'll get a series of invocations that all need to be deferred, but I guess it doesn't matter provided you're prepared to queue as many as arrive.
Also, you have to call the completion handler *eventually*, so if login fails (in the sense that you give up after repeated attempts), you should probably invoke the completion handlers with nil window parameters, then quit the application, since AFAIK there's no way to restart the restoration process later in the app's existing lifetime.
I dunno, though. Maybe this is abusing the resume mechanism too.
_______________________________________________
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