My question is pretty straightforward : I have a class which is the delegate of several NSAnimations and I will need to give a name/identifier to my NSAnimation so that the sorting of all the -(void)animationDidEnd:(NSAnimation *)animation
messages can be done easily.
Any ideas on how to achieve it ?
EDIT : Should I analyze the lack of answer as meaning that I shouldn't be using NSAnimation
at all ?
Source : Is NSAnimation deprecated ?
Well, turns out animations should be handled by Core Animation : it's more powerful than NSAnimation
, more systematic and you can label your animation using a key :
#import <QuartzCore/QuartzCore.h>
CALayer* myLayer;
CAKeyframeAnimation *anim = [CAKeyframeAnimation animationWithKeyPath:@"position"];
anim.path = [NSBezierPath bezierPathWithRect:NSMakeRect(0,0,100,100)];
anim.repeatCount = 0;
anim.duration = 3.0;
[bounceLayer addAnimation:anim forKey:@"MyAnimationKey"];
Furthermore, there are nice delegate methods such as : - (void)animationDidStart:(CAAnimation *)theAnimation
to achieve what we had in mind.