Re: Automatically restore last saved document on application launch

2016-03-12 Thread Eric Gorr
I continued the conversation with Quincey Morris offline, but if anyone is 
curious or might be caught by this in the future...

The answer to this question does not involve a coding problem. As some probably 
understood, default application created by Xcode should automatically support 
the Resume functionality. What was blocking this from working was the System 
Preference:

General -> Close windows when quitting an app

This preference was selected and closed the windows of the app upon quitting 
which naturally means there is nothing to resume when the app relaunches.


> On Mar 11, 2016, at 9:38 PM, Eric Gorr  wrote:
> 
> There are still several key details I seem to be missing.
> 
> I have a new commit 
> 
> https://github.com/ericgorr/last_saved/commit/ba462a19062fefde68f7e0f4459a0c8293332e9f
>  
> 
> 
> which shows an attempt to implement some of this.
> 
> I am using my AppDelegate as the restoration class. I have the following in 
> my AppDelegate class:
> 
> static func restoreWindowWithIdentifier( identifier: String, state: 
> NSCoder, completionHandler: (NSWindow?, NSError?) -> Void )
> {
> let storyboard  = NSStoryboard( name: "Main", bundle: nil )
> let windowController= 
> storyboard.instantiateControllerWithIdentifier( "Document Window Controller" 
> ) as! NSWindowController   
> }
> 
> Based on other information I found, I believe it is correct to use create my 
> storyboard…but, what else should go in here considering that I am using core 
> data to store the document data.
> 
> One problem I have is that restoreWindowWithIdentifier is never called. Why 
> might this be?
> 
> In the Document class I have:
> 
> override func makeWindowControllers()
> {
> //
> // Returns the Storyboard that contains your Document window.
> //
> let storyboard  = NSStoryboard( name: "Main", bundle: nil )
> let windowController= 
> storyboard.instantiateControllerWithIdentifier( "Document Window Controller" 
> ) as! NSWindowController
> let theWindow   = windowController.window!
> 
> theWindow.restorationClass  = AppDelegate.self
> theWindow.identifier= "last_saved_window"
> 
> self.addWindowController( windowController )
> }
> 
> to setup the window for restoration. Does this look correct?
> 
> 
> 
> 
> 
> 
>> On Mar 11, 2016, at 2:14 AM, Quincey Morris 
>> > > wrote:
>> 
>> On Mar 10, 2016, at 17:05 , Eric Gorr > > wrote:
>>> 
>>> I have a Core Data Document Based OS X application written in swift and 
>>> using storyboards. Whenever I build and launch the app, instead of 
>>> automatically opening the last opened document(s), it will create a new 
>>> document. What I want to be able to do is have the application 
>>> automatically restore whatever documents were last opened on application 
>>> launch, if they are available. How can I do this?
>> 
>> I believe there’s nothing special to ease this case (as opposed to 
>> NSDocument-based apps, which have state restoration support provided by 
>> NSDocumentController). You’ll have to do this manually:
>> 
>> 1. Set a state restoration class on each restorable window. You might use 
>> the window controller class, or the app delegate class, depending on what’s 
>> convenient.
>> 
>> 2. Implement the state restoration protocol in this class. This is basically 
>> a way of establishing a link between a restoration ID and a window that may 
>> or may not exist at the time this is invoked.
>> 
>> 3. Save and restore custom state in a suitable place, either a subclass of 
>> NSWindow, or a subclass of NSWindowController: a NSResponder subclass that’s 
>> going to be in the responder chain.
>> 
>> The trick to it is to remember that state restoration is a layer on top of 
>> normal NSWindow handling, so you’re in charge of (re)creating the windows 
>> when the app launches. Window controllers are not intrinsically involved in 
>> state restoration, but in most cases (I’d imagine) it’s going to be easiest 
>> to centralize the actual work in the window controller.
>> 
>> There’s been another thread about this in the last week or so, where we went 
>> into this in a fair amount of detail.
> 

___

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

Re: Automatically restore last saved document on application launch

2016-03-12 Thread Bill Cheeseman

> On Mar 12, 2016, at 8:53 AM, Eric Gorr  wrote:
> 
> The answer to this question does not involve a coding problem. As some 
> probably understood, default application created by Xcode should 
> automatically support the Resume functionality. What was blocking this from 
> working was the System Preference:
> 
> General -> Close windows when quitting an app
> 
> This preference was selected and closed the windows of the app upon quitting 
> which naturally means there is nothing to resume when the app relaunches.


The same thing happens, for the same reason, if your application implements the 
-applicationShouldTerminateAfterLastWindowClosed: delegate method and return 
YES.

-- 

Bill Cheeseman - wjcheese...@comcast.net

___

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

creating an application on the Mac

2016-03-12 Thread Scott Berry
Hello there,

I am wondering if I am creating a wizard because I need to step people through 
a process of choosing from a few devices on the Mac such as a Victor Stream 
Reader which is a digital reader for the blind that uses an SD card and a 
Trekker Breeze GPS which uses and SD card, how do I go about creating different 
pages of the wizard which are blind friendly.  I was a little hesitant to use 
the page object because I know in IOS apps that this does not work well for 
those of us who are blind.  I was thinking along the lines of doing view 
controllers like I would on an IOS application.  Does this work for the Mac?  
It seeming not to work for me because I can’t get the story board to recognize 
the new View Controller whether I put it in the story board or whether I put it 
in the area where it tells me that my size and dimensions are incorrect.  What 
do you guys suggest as the best method?



___

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

Re: creating an application on the Mac

2016-03-12 Thread Jens Alfke

> On Mar 12, 2016, at 3:13 PM, Scott Berry  wrote:
> 
> Hello there,
> 
> I am wondering if I am creating a wizard because I need to step people 
> through a process of choosing from a few devices on the Mac such as a Victor 
> Stream Reader which is a digital reader for the blind that uses an SD card 
> and a Trekker Breeze GPS which uses and SD card, how do I go about creating 
> different pages of the wizard which are blind friendly. 

In the past I’ve implemented wizard/assistant interfaces using an NSTabView, 
with one page per tab. I configured the view to hide the tabs, and wired the 
back/forward buttons up to the actions to go to the previous/next tab.

(I don’t know about the accessibility implications, but I assume that as a 
standard system class, NSTabView is accessible.)

—Jens
___

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

Re: creating an application on the Mac

2016-03-12 Thread SevenBits
On Saturday, March 12, 2016, Jens Alfke  wrote:

>
> > On Mar 12, 2016, at 3:13 PM, Scott Berry  > wrote:
> >
> > Hello there,
> >
> > I am wondering if I am creating a wizard because I need to step people
> through a process of choosing from a few devices on the Mac such as a
> Victor Stream Reader which is a digital reader for the blind that uses an
> SD card and a Trekker Breeze GPS which uses and SD card, how do I go about
> creating different pages of the wizard which are blind friendly.
>
> In the past I’ve implemented wizard/assistant interfaces using an
> NSTabView, with one page per tab. I configured the view to hide the tabs,
> and wired the back/forward buttons up to the actions to go to the
> previous/next tab.


I've done this as well, and it works just fine.


>
> (I don’t know about the accessibility implications, but I assume that as a
> standard system class, NSTabView is accessible.)
>
> —Jens
> ___
>
> 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/sevenbitstech%40gmail.com
>
> This email sent to sevenbitst...@gmail.com 
___

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