Returning NSNull from actionForLayer:forKey

Posted by MrHen on Stack Overflow See other posts from Stack Overflow or by MrHen
Published on 2010-05-17T22:12:30Z Indexed on 2010/05/21 1:40 UTC
Read the original article Hit count: 245

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?

© Stack Overflow or respective owner

Related posts about iphone-sdk

Related posts about xcode