Re: Programmatically Clear Dirty NSDocument
Re: Programmatically Clear Dirty NSDocument
- Subject: Re: Programmatically Clear Dirty NSDocument
- From: Jens Alfke <email@hidden>
- Date: Mon, 07 Nov 2016 11:24:04 -0800
> 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.
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. (Or you could just do things the modern way, with dispatch_async and a block.)
—Jens
* 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.
_______________________________________________
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