I am having a crash in my CALayer subclass when I remove myself as an observer in -(void)dealloc:
- (void)dealloc {
[[NSUserDefaults standardUserDefaults] removeObserver:self forKeyPath:@"showColorLabels"];
[colorLabel release];
[_color release];
[super dealloc];
}
An exception is thrown. It says that self has not been added as an observer. This only happens in a certain case, after [CATransaction flush] is called.
I used Instruments to see when the object was allocated. It says it was allocated with the call CALayerGetPresentationLayer(). I am not sure how this works, but I guess this is a copy of my original layer, so init was never called, and I was never added as an observer.
How can I either check that I am an observer before removing myself, or maybe tell if I am a presentation layer?
Bridger Maxwell