From 13da33fc4a6cc9767a1ea545e620772c21d94fbd Mon Sep 17 00:00:00 2001 From: Imanol Fernandez Date: Sat, 27 Aug 2016 11:58:59 +0200 Subject: [PATCH] Fix issue #216: crash when combining programmatically created offset animations in consecutive block callbacks --- MGSwipeTableCell/MGSwipeTableCell.m | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/MGSwipeTableCell/MGSwipeTableCell.m b/MGSwipeTableCell/MGSwipeTableCell.m index 3ac9c6b..ea39343 100644 --- a/MGSwipeTableCell/MGSwipeTableCell.m +++ b/MGSwipeTableCell/MGSwipeTableCell.m @@ -1105,8 +1105,9 @@ -(void) animationTick: (CADisplayLink *) timer [timer invalidate]; _displayLink = nil; if (_animationCompletion) { - _animationCompletion(YES); + void (^callbackCopy)(BOOL finished) = _animationCompletion; //copy to avoid duplicated callbacks _animationCompletion = nil; + callbackCopy(YES); } } } @@ -1123,8 +1124,9 @@ -(void) setSwipeOffset:(CGFloat)offset animation: (MGSwipeAnimation *) animation _displayLink = nil; } if (_animationCompletion) { //notify previous animation cancelled - _animationCompletion(NO); + void (^callbackCopy)(BOOL finished) = _animationCompletion; //copy to avoid duplicated callbacks _animationCompletion = nil; + callbackCopy(NO); } if (offset !=0) { [self createSwipeViewIfNeeded];