Reputation: 99
I am doing a simple document based application. I've implemented readFromData and dataOfType function. Creating a newDocument and saveDocument are working. However, the question is how to set up save notification when user clicks Close. I add some data in my application and when I click close, it just directly close. There is no save notification. I think it was supposed to have it in document based application.
I tried windowWillClose:(NSNotification*)a, having an alertsheet. The alert comes and window closes immediately.
What I am missing?
Upvotes: 3
Views: 256
Reputation: 2917
Use NSDocument -updateChangeCount: method to track changes in your document. Like :
// add some data to theDocument
[theDocument updateChangeCount:NSChangeDone];
But just read the documentation, you may not need to update change count yourself, if you use default document undo manager.
Cheers
Upvotes: 2
Reputation: 46543
Implement this kind of logic, and you will be done.
- (BOOL)isDocumentEdited{
if (somethingGotChanged){
return YES;
}
else{
return NO;
}
//or return somethingGotChanged; //*** make somethingGotChanged BOOL
}
Here, somethingGotChanged is a flag, which you have to set based on you editing on the data.
Upvotes: 1