Re: Block gets NULL-ified when animation completes

2013-08-15 Thread Andreas Grosam
The collection view will very likely have corresponding ivars for the animation block and its completion handler. If that's the case, it should (shall) create a copy of the anonymous animation (updates) and completion block when receiving them in `performBatchUpdate:completion:`. Now,

Re: Block gets NULL-ified when animation completes

2013-08-15 Thread Vlad Alekseev
Turns out, this is a bug in UICollectionView or even ARC. And it is easily reproducible. You can download Apple's sample code: http://developer.apple.com/library/ios/samplecode/CollectionView-Simple/Introduction/Intro.html and modify it to return 0 items to the collection view. Then try to

Re: Block gets NULL-ified when animation completes

2013-08-15 Thread Jens Alfke
On Aug 15, 2013, at 5:41 AM, Vlad Alekseev ippo...@me.com wrote: dispatch_block_t block = ^{ printf(finished); }; UICollectionViewFlowLayout *layout = (UICollectionViewFlowLayout *)self.collectionView.collectionViewLayout; [self.collectionView performBatchUpdates:^{

Re: Block gets NULL-ified when animation completes

2013-08-15 Thread Vlad Alekseev
As I said before, this is a bug in your code. ‘block’ needs to be copied since it is going to be called after the calling function returns. I work under ARC. It goes to heap automatically. Also, there are some circumstances that proves your wrong guess: 1. If I copy it manually, it still

Re: Block gets NULL-ified when animation completes

2013-08-15 Thread Ken Thomases
On Aug 15, 2013, at 9:49 AM, Jens Alfke wrote: On Aug 15, 2013, at 5:41 AM, Vlad Alekseev ippo...@me.com wrote: dispatch_block_t block = ^{ printf(finished); }; UICollectionViewFlowLayout *layout = (UICollectionViewFlowLayout *)self.collectionView.collectionViewLayout;

Block gets NULL-ified when animation completes

2013-08-14 Thread Vlad Alekseev
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 = ^{

Re: Block gets NULL-ified when animation completes

2013-08-14 Thread Jens Alfke
Sounds like you forgot to copy the block — if it’s being invoked after the calling function returns (as a completion handler would) it needs to be copied so it can survive the loss of its original stack frame. —Jens ___ Cocoa-dev mailing list

Re: Block gets NULL-ified when animation completes

2013-08-14 Thread Vlad Alekseev
Hey, ARC should drive this for me. If it wouldn’t, then it wouldn’t work in case if there are items in the collection view. Tried to copy manually - no results. BTW, not only «finish», but also «completion» gets NULLified at the last step. Vlad. 15 авг. 2013 г., в 9:22, Jens Alfke