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 (Cocoa-dev@lists.apple.com) 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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com