Re: Receiver type for instance message is a forward declaration
Re: Receiver type for instance message is a forward declaration
- Subject: Re: Receiver type for instance message is a forward declaration
- From: Carl Hoefs <email@hidden>
- Date: Tue, 10 May 2016 16:22:51 -0700
> On May 10, 2016, at 4:13 PM, Quincey Morris <email@hidden> wrote:
>
> On May 10, 2016, at 16:05 , Carl Hoefs <email@hidden <mailto:email@hidden>> wrote:
>>
>> I'm not sure how context is to be used here
>
> It has to be a value that’s unique to the piece of code that tests it. In effect, this means unique to the class that creates and responds to the observations. If you’re in Obj-C, the usual trick is to use the static address of something, like this:
>
>> static void* kvoContext = &kvoContext;
>
> This exploits a quirk of C to initialize the static variable as containing its own address. That means you can specify the ‘context:’ parameter as EITHER ‘kvoContext’ OR ‘&kvoContext’, so that forgetting the & is harmless.
>
>
Okay... It appears that for some odd reason, once in a blue moon, 'object' and 'keyPath' aren't what they're supposed to be, so I super it, and it blows.
- (void) observeValueForKeyPath:(NSString *)keyPath
ofObject:(id)object
change:(NSDictionary *)change
context:(void *)context
{
if ((object == uploadQueue) && [keyPath isEqualToString:@"operations"]) {
[self performSelectorOnMainThread:@selector(displayQueueInfo)
withObject:nil
waitUntilDone:NO];
} else {
[super observeValueForKeyPath:keyPath
ofObject:object
change:change
context:context];
}
}
I will set 'context' and use it in my check instead.
-Carl
_______________________________________________
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