Block gets NULL-ified when animation completes
Block gets NULL-ified when animation completes
- Subject: Block gets NULL-ified when animation completes
- From: Vlad Alekseev <email@hidden>
- Date: Fri, 09 Aug 2013 18:57:11 +0400
Hey!
I have a method where I update my collection view's layout parameter and want to have a completion block invoked when animation completes:
- (void)transitionAnimated:(BOOL)animated completion:(dispatch_block_t)completion
{
dispatch_block_t updates = ^{
self.layout.maximumScale = self.maximumScale;
};
dispatch_block_t finish = ^{
if (completion) {
completion();
}
};
if (animated) {
self.collectionView.userInteractionEnabled = NO;
[self.collectionView performBatchUpdates:^{
updates();
} completion:^(BOOL finished) {
self.collectionView.userInteractionEnabled = YES;
finish();
}];
}
else {
updates();
[self.layout invalidateLayout];
finish();
}
}
It works as expected if collection view contains some items. But it crashes if collection view is empty. And it crashes here:
} completion:^(BOOL finished) {
self.collectionView.userInteractionEnabled = YES;
finish(); // ---- CRASH because finish == NULL
}];
Debugger says that finish is nil:
(lldb) p finish
(dispatch_block_t) $1 = <parent is NULL>
What is going on with that block? Any ideas why it gets NULL-ified?
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden