Programmatically Clear Dirty NSDocument
Programmatically Clear Dirty NSDocument
- Subject: Programmatically Clear Dirty NSDocument
- From: Richard Charles <email@hidden>
- Date: Mon, 07 Nov 2016 11:46:00 -0700
I have a dirty document that needs to be cleared programmatically. So I try the following but it does not work. I have verified that updateChangeCount: is being called but the document change count state is not being changed. This code is executed on the main thread.
// Called from a controller.
// This does not work.
NSDocument *doc = self.myDocument;
[doc updateChangeCount:NSChangeUndone];
So next I try the following. When a function key is pressed the following code is executed. This is exactly the same as before but it now works! The document is no longer dirty. This code is also executed on the main thread.
// Called with a function key press.
// This works fine.
NSDocument *doc = self.myDocument;
[doc updateChangeCount:NSChangeUndone];
So next I try the following using performSelector. But this does not work at all when called from a controller or when called with a function key press.
// This does not work at all.
NSDocument *doc = self.myDocument;
[doc performSelector:@selector(updateChangeCount:)
withObject:@(NSChangeUndone)
afterDelay:0];
So why does successfully calling -[NSDocument updateChangeCount:] have a hidden dependency on the run loop?
--Richard Charles
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden