Re: Programmatically Clear Dirty NSDocument
Re: Programmatically Clear Dirty NSDocument
- Subject: Re: Programmatically Clear Dirty NSDocument
- From: Richard Charles <email@hidden>
- Date: Mon, 07 Nov 2016 15:02:03 -0700
> On Nov 7, 2016, at 2:33 PM, Quincey Morris <email@hidden> wrote:
>
> On Nov 7, 2016, at 10:46 , Richard Charles <email@hidden> wrote:
>>
>> This is exactly the same as before but it now works!
>
> Regarding that particular mystery, NSChangeUndone decrements the change count. If it happened to be 1 when you tried this, the document would stop being dirty. Presumably, in your first test, the change count was greater than 1. As Jens said, the third test was invalid.
Yes this has been a mystery. Thanks for the insight. Up until a day ago I did not even know that NSDocument had something called a change count.
It appears that the following is what was happening.
> On Nov 7, 2016, at 11:46 AM, Richard Charles <email@hidden> wrote:
>
> // Called from a controller.
> // This does not work.
> NSDocument *doc = self.myDocument;
> [doc updateChangeCount:NSChangeUndone];
The above did not work because it needs to be called later in the run loop.
> // Called with a function key press.
> // This works fine.
> NSDocument *doc = self.myDocument;
> [doc updateChangeCount:NSChangeUndone];
The above worked fine because it was done manually in a dedicated run of the run loop with a key press.
> // This does not work at all.
> NSDocument *doc = self.myDocument;
> [doc performSelector:@selector(updateChangeCount:)
> withObject:@(NSChangeUndone)
> afterDelay:0];
As Jens pointed out the above could never work.
But I am off and running now. Thanks so much.
--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