JacktheSparrow
JacktheSparrow

Reputation: 11

Retrieve the CAKeyframeAnimationKey's key in AnimationDidStop

I have multiple CAKeyframeAnimation objects, each with a unique key like the following:

 .....
 [myAnimation setValues:images];
 [myAnimation setDuration:1];
 ....
 [myLayer addAnimation:myAnimation forKey:@"unique key"];

My question is, if I have multiple animation like this and each with a unique key, how do I retrieve their keys in the method AnimationDidStop? I want to be able to do something like this:

 -(void)animationDidStop:(CAAnimation*)animation finished:(BOOL)flag{
 if(..... ==@"uniquekey1"){
 //code to handle this specific animation here:
 }else if(.... ==@"uiquekey2"){
 //code to handle this specific animation here:
 }
 }

Upvotes: 1

Views: 368

Answers (1)

rob mayoff
rob mayoff

Reputation: 385610

Theres no public API to retrieve the key. If you have the layer object you can send it animationsKeys to get an array of all its animation keys. Then you can test each one using animationForKey:.

The easiest solution (other than using a separate delegate for each animation) is to create an NSMutableDictionary. Use the animation object as a key and its animation key string as its value.

Upvotes: 1

Related Questions