I was wondering what you should set the Context pointer in KVO when you are observing a property. I'm just starting to use KVO and I haven't gleaned too much from the documentation. I see on this page: http://www.jakeri.net/2009/12/custom-callout-bubble-in-mkmapview-final-solution/ the author does this:
[annView addObserver:self
forKeyPath:@"selected"
options:NSKeyValueObservingOptionNew
context:GMAP_ANNOTATION_SELECTED];
And then in the callback, does this:
- (void)observeValueForKeyPath:(NSString *)keyPath
ofObject:(id)object
change:(NSDictionary *)change
context:(void *)context{
NSString *action = (NSString*)context;
if([action isEqualToString:GMAP_ANNOTATION_SELECTED]){
I'm assuming in this scenario, the author just creates a string to be identified later in the callback.
Then in iOS 5 Pushing the Limits book, I see he does this:
[self.target addObserf:self forKeyPath:self.property options:0 context:(__bridge void *)self];
callback:
if ((__bridge id)context == self) {
}
else {
[super observeValueForKeyPath .......];
}
I was wondering if there is a standard or best practices to pass into the context pointer?