When Application quits, NSDocument's isDocumentEdited method always returns false
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}
In a document-based application, any change in a document is signalled by a
[self updateChangeCount: NSChangeDone];
At any time, when debugging, the [document isEdited]
returns TRUE, as far as the document has been edited. The doc's window displays "Modified" besides the document's name. When I quit application, my app delegate reviews all opened documents, and check whether they've been edited or not, using this loop:
NSUInteger needsSaving = 0;
while (count--) {
NSWindow *window = [windows objectAtIndex:count];
Document *document = [Document documentForWindow:window];
if (document && [document isDocumentEdited]) needsSaving++;
}
It appears that for any document —modified or not— the
[document isDocumentEdited];
always returns FALSE! So that the review change/save process cannot be called. If I check the [window isDocumentEdited]
, it also returns FALSE despite the fact that "Modified" is written in the title bar of the window.
When the applications quits, the changes are eventually saved (automatically) but without informing the user. This is a very disturbing behaviour!
Any idea of what could explain that the isDocumentEdited
boolean is reset to FALSE somewhere before entering this process?
I checked all the code to see if there wasn't any [self updateChangeCount: NSChangeCleared]
that could be run somewhere, but it's not the case. I can circumvent the problem using a custom updateChange counting system in my Document subclass, but I would rather use the built-in process.
Using Xcode 10 under Mojave, with a 10.12 target
macos save nsdocument document-based
add a comment |
In a document-based application, any change in a document is signalled by a
[self updateChangeCount: NSChangeDone];
At any time, when debugging, the [document isEdited]
returns TRUE, as far as the document has been edited. The doc's window displays "Modified" besides the document's name. When I quit application, my app delegate reviews all opened documents, and check whether they've been edited or not, using this loop:
NSUInteger needsSaving = 0;
while (count--) {
NSWindow *window = [windows objectAtIndex:count];
Document *document = [Document documentForWindow:window];
if (document && [document isDocumentEdited]) needsSaving++;
}
It appears that for any document —modified or not— the
[document isDocumentEdited];
always returns FALSE! So that the review change/save process cannot be called. If I check the [window isDocumentEdited]
, it also returns FALSE despite the fact that "Modified" is written in the title bar of the window.
When the applications quits, the changes are eventually saved (automatically) but without informing the user. This is a very disturbing behaviour!
Any idea of what could explain that the isDocumentEdited
boolean is reset to FALSE somewhere before entering this process?
I checked all the code to see if there wasn't any [self updateChangeCount: NSChangeCleared]
that could be run somewhere, but it's not the case. I can circumvent the problem using a custom updateChange counting system in my Document subclass, but I would rather use the built-in process.
Using Xcode 10 under Mojave, with a 10.12 target
macos save nsdocument document-based
When, in which method, do you check?
– Willeke
Nov 16 '18 at 17:03
in the applicationShouldTerminate: of the application delegate
– Denis
Nov 16 '18 at 17:27
I noticed that when a change is made in a document, all document windows get the "Modified" entry near window title, even for non modified documents
– Denis
Nov 16 '18 at 18:00
How do you create the documents, window controllers and windows? How is undo implemented?
– Willeke
Nov 16 '18 at 23:58
documents, window controllers and windows are created using IB (new in file menu, the rest created using makeWindowController). I disabled all undo operations to be sure that the undo system is not involved in the problem! I set up a turn around, using a self created flag, and the problem is solved in my app. But I would rather use the built-in system than circumvent it!
– Denis
Nov 17 '18 at 1:18
add a comment |
In a document-based application, any change in a document is signalled by a
[self updateChangeCount: NSChangeDone];
At any time, when debugging, the [document isEdited]
returns TRUE, as far as the document has been edited. The doc's window displays "Modified" besides the document's name. When I quit application, my app delegate reviews all opened documents, and check whether they've been edited or not, using this loop:
NSUInteger needsSaving = 0;
while (count--) {
NSWindow *window = [windows objectAtIndex:count];
Document *document = [Document documentForWindow:window];
if (document && [document isDocumentEdited]) needsSaving++;
}
It appears that for any document —modified or not— the
[document isDocumentEdited];
always returns FALSE! So that the review change/save process cannot be called. If I check the [window isDocumentEdited]
, it also returns FALSE despite the fact that "Modified" is written in the title bar of the window.
When the applications quits, the changes are eventually saved (automatically) but without informing the user. This is a very disturbing behaviour!
Any idea of what could explain that the isDocumentEdited
boolean is reset to FALSE somewhere before entering this process?
I checked all the code to see if there wasn't any [self updateChangeCount: NSChangeCleared]
that could be run somewhere, but it's not the case. I can circumvent the problem using a custom updateChange counting system in my Document subclass, but I would rather use the built-in process.
Using Xcode 10 under Mojave, with a 10.12 target
macos save nsdocument document-based
In a document-based application, any change in a document is signalled by a
[self updateChangeCount: NSChangeDone];
At any time, when debugging, the [document isEdited]
returns TRUE, as far as the document has been edited. The doc's window displays "Modified" besides the document's name. When I quit application, my app delegate reviews all opened documents, and check whether they've been edited or not, using this loop:
NSUInteger needsSaving = 0;
while (count--) {
NSWindow *window = [windows objectAtIndex:count];
Document *document = [Document documentForWindow:window];
if (document && [document isDocumentEdited]) needsSaving++;
}
It appears that for any document —modified or not— the
[document isDocumentEdited];
always returns FALSE! So that the review change/save process cannot be called. If I check the [window isDocumentEdited]
, it also returns FALSE despite the fact that "Modified" is written in the title bar of the window.
When the applications quits, the changes are eventually saved (automatically) but without informing the user. This is a very disturbing behaviour!
Any idea of what could explain that the isDocumentEdited
boolean is reset to FALSE somewhere before entering this process?
I checked all the code to see if there wasn't any [self updateChangeCount: NSChangeCleared]
that could be run somewhere, but it's not the case. I can circumvent the problem using a custom updateChange counting system in my Document subclass, but I would rather use the built-in process.
Using Xcode 10 under Mojave, with a 10.12 target
macos save nsdocument document-based
macos save nsdocument document-based
asked Nov 16 '18 at 16:40
DenisDenis
406418
406418
When, in which method, do you check?
– Willeke
Nov 16 '18 at 17:03
in the applicationShouldTerminate: of the application delegate
– Denis
Nov 16 '18 at 17:27
I noticed that when a change is made in a document, all document windows get the "Modified" entry near window title, even for non modified documents
– Denis
Nov 16 '18 at 18:00
How do you create the documents, window controllers and windows? How is undo implemented?
– Willeke
Nov 16 '18 at 23:58
documents, window controllers and windows are created using IB (new in file menu, the rest created using makeWindowController). I disabled all undo operations to be sure that the undo system is not involved in the problem! I set up a turn around, using a self created flag, and the problem is solved in my app. But I would rather use the built-in system than circumvent it!
– Denis
Nov 17 '18 at 1:18
add a comment |
When, in which method, do you check?
– Willeke
Nov 16 '18 at 17:03
in the applicationShouldTerminate: of the application delegate
– Denis
Nov 16 '18 at 17:27
I noticed that when a change is made in a document, all document windows get the "Modified" entry near window title, even for non modified documents
– Denis
Nov 16 '18 at 18:00
How do you create the documents, window controllers and windows? How is undo implemented?
– Willeke
Nov 16 '18 at 23:58
documents, window controllers and windows are created using IB (new in file menu, the rest created using makeWindowController). I disabled all undo operations to be sure that the undo system is not involved in the problem! I set up a turn around, using a self created flag, and the problem is solved in my app. But I would rather use the built-in system than circumvent it!
– Denis
Nov 17 '18 at 1:18
When, in which method, do you check?
– Willeke
Nov 16 '18 at 17:03
When, in which method, do you check?
– Willeke
Nov 16 '18 at 17:03
in the applicationShouldTerminate: of the application delegate
– Denis
Nov 16 '18 at 17:27
in the applicationShouldTerminate: of the application delegate
– Denis
Nov 16 '18 at 17:27
I noticed that when a change is made in a document, all document windows get the "Modified" entry near window title, even for non modified documents
– Denis
Nov 16 '18 at 18:00
I noticed that when a change is made in a document, all document windows get the "Modified" entry near window title, even for non modified documents
– Denis
Nov 16 '18 at 18:00
How do you create the documents, window controllers and windows? How is undo implemented?
– Willeke
Nov 16 '18 at 23:58
How do you create the documents, window controllers and windows? How is undo implemented?
– Willeke
Nov 16 '18 at 23:58
documents, window controllers and windows are created using IB (new in file menu, the rest created using makeWindowController). I disabled all undo operations to be sure that the undo system is not involved in the problem! I set up a turn around, using a self created flag, and the problem is solved in my app. But I would rather use the built-in system than circumvent it!
– Denis
Nov 17 '18 at 1:18
documents, window controllers and windows are created using IB (new in file menu, the rest created using makeWindowController). I disabled all undo operations to be sure that the undo system is not involved in the problem! I set up a turn around, using a self created flag, and the problem is solved in my app. But I would rather use the built-in system than circumvent it!
– Denis
Nov 17 '18 at 1:18
add a comment |
0
active
oldest
votes
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53342049%2fwhen-application-quits-nsdocuments-isdocumentedited-method-always-returns-fals%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53342049%2fwhen-application-quits-nsdocuments-isdocumentedited-method-always-returns-fals%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
When, in which method, do you check?
– Willeke
Nov 16 '18 at 17:03
in the applicationShouldTerminate: of the application delegate
– Denis
Nov 16 '18 at 17:27
I noticed that when a change is made in a document, all document windows get the "Modified" entry near window title, even for non modified documents
– Denis
Nov 16 '18 at 18:00
How do you create the documents, window controllers and windows? How is undo implemented?
– Willeke
Nov 16 '18 at 23:58
documents, window controllers and windows are created using IB (new in file menu, the rest created using makeWindowController). I disabled all undo operations to be sure that the undo system is not involved in the problem! I set up a turn around, using a self created flag, and the problem is solved in my app. But I would rather use the built-in system than circumvent it!
– Denis
Nov 17 '18 at 1:18