• 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: Opening previous document by default
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Opening previous document by default


  • Subject: Re: Opening previous document by default
  • From: Matt Gemmell <email@hidden>
  • Date: Sat, 21 Jun 2003 09:50:00 +0100

On 20/6/03 at 8:31 pm, John A. Debay said:

> When my application starts up, I would like it to open the last
> document the user was working on. If no previous document is found, I
> want to open a new, untitled document. In order to achieve this, I
> subclassed NSDocumentController and overrode
> openUntitledDocumentOfType:display: to open the last document
> instead. This worked great until I clicked File -> New, which called
> the same code, and which opened up the previous document again
> instead of a new document. I'm having trouble seeing how my document
> controller can distinguish between opening a document by default when
> the application is created but opening a new document when directed
> to by the user.

If you have an application delegate object, you could override
-applicationShouldOpenUntitledFile: to return NO if a previous document
is found. In that case, your app won't try to open a new document when
it finishes launching.

You could then open the previous document (if it exists) in an
appropriate method in your NSDocumentController subclass, such as
-awakeFromNib. You then don't need to override
openUntitledDocumentOfType:display: at all.

Cheers,
-Matt

--
Matt Gemmell
Scotland Software
http://www.scotlandsoftware.com/
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

References: 
 >Opening previous document by default (From: "John A. Debay" <email@hidden>)

  • Prev by Date: Re: Not a drawer but a ... ?
  • Next by Date: Re: scroll view & drop-n-drag
  • Previous by thread: Opening previous document by default
  • Next by thread: Re: Opening previous document by default
  • Index(es):
    • Date
    • Thread