domhofmann / PRTween

Lightweight tween library for iOS
BSD 2-Clause "Simplified" License
459 stars 63 forks source link

PRTweenOperation retain? #12

Closed typeoneerror closed 12 years ago

typeoneerror commented 12 years ago

I'm using PRTweenCGPointLerp helper method and I'm wondering how to release the operation when the animation is finished. Basically, with the following example, _gridB is retained by PRTween somewhere and then it never gets released when I call [_gridB release] later. If I remove the tween, it is released fine. Seems like PRTweenOperation is retaining a reference in there somewhere. Where in the classes do the generated PRTweenOperations get released?

[PRTweenCGPointLerp lerp:_gridB 
                property:@"center" 
                    from:_gridB.center 
                      to:CGPointMake(self.gridB.center.x, kGridCollapsedOffset)
                duration:0.8 
          timingFunction:&PRTweenTimingFunctionElasticOut
             updateBlock:NULL 
           completeBlock:^{

             }];
domhofmann commented 12 years ago

Good catch.

This is due to unreleased PRTweenOperations inside the shorthand functions. Check out the implementation of + (PRTweenOperation *)tween:(id)object property:(NSString*)property from:(CGFloat)from to:(CGFloat)to duration and you'll find:

PRTweenOperation *operation = [PRTweenOperation new];

We need to insert a release at the bottom of these methods. I can push a fix tomorrow evening, or feel free to take care of it yourself if it's pressing.

domhofmann commented 12 years ago

To be clear, PRTweenOperations are still retained by the timeline instance while an animation is occurring and are released automatically when the animation is finished. They're supposed to deallocate at this point, but that wasn't happening due to the extra retain.