Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > Document-based App won't save before quit or close

Document-based App won't save before quit or close
Thread Tools
Brass
Professional Poster
Join Date: Nov 2000
Location: Tasmania, Australia
Status: Offline
Reply With Quote
Nov 19, 2003, 05:57 PM
 
I've written a few Cocoa/Obj-C applications before, but never document-based until now.

From what I've read in the documentation, the handling of save dialogues should be automatic, so that they just appear automatically before close/quit if changes have been made to the document. However, this is not happening for me, despite the fact that I've used "setDocumentEdited:YES" and the document window's close widget shows the little dot indicating that it's been edited.

But if I close the document window, or quit the application, it just closes/quits, without any save dialogue. Should it if fact be displaying the save dialogue automatically at this point?

If so, why would it not be working?

If not, how do I get it to work? The windowShouldClose delegate method doesn't get invoked on quit, only on close, so I'd have to get the applicationShouldTerminate to send performClose to all windows, but then according to the documentation, I shouldn't have to do this for document-based applications.

Any help much appreciated.
     
Diggory Laycock
Professional Poster
Join Date: Oct 2001
Location: London
Status: Offline
Reply With Quote
Nov 19, 2003, 09:09 PM
 
A new document based application project comes with empty method implementations for dataRepresentationOfType: and loadDataRepresentation:ofType: in the custom subclass that is automatically created for you.You should implement these methods to support reading and writing of simple files.


dataRepresentationOfType: should provide the contents of the document as an NSData object, formatted as the requested type.


loadDataRepresentation:ofType: should be able to read in the document contents from the given NSData, interpreting the data as the given type.


See the Sketch application source for an example of how one application implements these methods.
from http://developer.apple.com/documenta.../uid/10000006i
     
Brass  (op)
Professional Poster
Join Date: Nov 2000
Location: Tasmania, Australia
Status: Offline
Reply With Quote
Nov 19, 2003, 09:13 PM
 
Thanks for that, but I'd already read that several times before. It would be more helpful if you'd point out which part of that document would help me.

As it turns out, I've already solved the problem. I needed to use "updateChangeCount" not "setDocumentEdited".
     
   
 
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Top
Privacy Policy
All times are GMT -4. The time now is 02:34 PM.
All contents of these forums © 1995-2017 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.8 © 2000-2017, Jelsoft Enterprises Ltd.,