Returning NSNull from actionForLayer:forKey
- by MrHen
If I implement the CALayer delegate method actionForLayer:forKey I can return [NSNull null] to force the CALayer to not animate any changes. Unfortunately, [NSNull null] doesn't implement the CAAction delegate and XCode kicks out the following warning:
warning: class 'NSNull' does not implement the 'CAAction' protocol
Here is the method code:
- (id<CAAction>)actionForLayer:(CALayer *)theLayer
forKey:(NSString *)theKey {
//This disables the animations when moving things around
//Also, don't animate the selection box. It was doing weird things
if(undoGroupStarted || theLayer == self.selectionBox) {
return [NSNull null];
} else {
return nil;
}
}
Am I doing something wrong? Is returning [NSNull null] bad behavior? If so, what is another way to do what I am trying to do here? If not, how do I make the compiler happy?