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 14:41:52 -0700
> On Nov 7, 2016, at 12:24 PM, Jens Alfke <email@hidden> wrote:
>
>> On Nov 7, 2016, at 10:46 AM, Richard Charles <email@hidden> wrote:
>>
>> [doc performSelector:@selector(updateChangeCount:)
>> withObject:@(NSChangeUndone)
>> afterDelay:0];
>
> That one definitely won’t work. The parameter to updateChangeCount: is an integer (enum) value, not an object reference, but you’re calling it with an NSNumber object. The value actually passed to the method will be a garbage value based on the raw address* of the NSNumber object.
You are right, the method is passed a garbage value! I was under the mistaken assumption that the frameworks would take care of this conversion for me. (Cocoa magic has cast a spell on me.)
> If you want to use a delayed-perform to call a method that takes a non-object parameter, you have to create a new method that makes the call you want, then invoke _that_ method using a delayed perform.
That works.
> (Or you could just do things the modern way, with dispatch_async and a block.)
That also works.
> * I’m aware that small integers don’t turn into real NSNumber objects on the heap, rather a tagged pointer, but the result is the same: a pointer that will result in a garbage value when interpreted as an integer.
Very accurate answer Jens. Thanks so much for the help.
Life is good again. :)
--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