• 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: saveDocument newbie question
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: saveDocument newbie question


  • Subject: Re: saveDocument newbie question
  • From: "Alan Smith" <email@hidden>
  • Date: Mon, 19 Jun 2006 10:45:40 -0400

Hi Neto,

If you're using NSDocument, that is if you're app in an editor of some
sort like TextEdit, there already is a method the will save the file
before quiting. Enter updateChangeCount:.

Using code like this you're app will save all unseaved changes, normally.

- (IBAction)textWasEnteredInTextView:(id)sender
{
     [self updateChangeCount:NSChangeDone];
}

If you hooked that up as the action of a NSTextView in your
MyDocument.nib file (or whatever you're calling it) it will put that
familiar dot in the red close button of your window. When that window
is closed, even if the app is quitting, the user will be asked if they
want to save it. Note that that method (textWasEnteredInTextView) will
have to be in your NSDocument.m file (or whatever you're calling your
NSDocument subclass).

Check out (http://developer.apple.com/documentation/Cocoa/Reference/ApplicationKit/Classes/NSDocument_Class/Reference/Reference.html#//apple_ref/doc/c_ref/NSDocumentChangeType)
for more information on this NSDocument method (updateChangeCount).

I hope this helps, Alan

--
// Quotes from yours truly -------------------------
"You don't forget, you just don't remember."
"Maturity resides in the mind."
"Silence is the Universe's greatest gift."
"Don't waste your life doing things others have already done."
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: saveDocument newbie question
      • From: Neto <email@hidden>
References: 
 >Excluding native file type from saveDocumentTo: accessory view. (From: Joshua Scott Emmons <email@hidden>)
 >saveDocument newbie question (From: Neto <email@hidden>)
 >Re: saveDocument newbie question (From: Andrew Merenbach <email@hidden>)

  • Prev by Date: Re: Problem in simulating the events
  • Next by Date: Re: Problem in simulating the events
  • Previous by thread: Re: saveDocument newbie question
  • Next by thread: Re: saveDocument newbie question
  • Index(es):
    • Date
    • Thread