• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Block gets NULL-ified when animation completes
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Block gets NULL-ified when animation completes


  • Subject: Re: Block gets NULL-ified when animation completes
  • From: Vlad Alekseev <email@hidden>
  • Date: Thu, 15 Aug 2013 16:41:04 +0400

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 perform the following code:

dispatch_block_t block = ^{
    printf("finished");
};

UICollectionViewFlowLayout *layout = (UICollectionViewFlowLayout *)self.collectionView.collectionViewLayout;
[self.collectionView performBatchUpdates:^{
    layout.minimumInteritemSpacing = 20;
} completion:^(BOOL finished) {
    block();
}];

It will crash since `finish` will be `nil`. But if you make data source to return non-zero item count to the collection view then everything will work good.

Created a bug report with ID 14744561. Affects iOS 6.0 and above.

You may refer to the Apple Dev Forums discussion thread: https://devforums.apple.com/thread/198531?tstart=0

Thanks!

Vlad.

15 авг. 2013 г., в 9:25, Vlad Alekseev <email@hidden> написал(а):

> 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 <email@hidden> написал(а):
>
>> 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 (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


  • Follow-Ups:
    • Re: Block gets NULL-ified when animation completes
      • From: Jens Alfke <email@hidden>
References: 
 >Block gets NULL-ified when animation completes (From: Vlad Alekseev <email@hidden>)
 >Re: Block gets NULL-ified when animation completes (From: Jens Alfke <email@hidden>)
 >Re: Block gets NULL-ified when animation completes (From: Vlad Alekseev <email@hidden>)

  • Prev by Date: Find bar in a text view
  • Next by Date: Re: Dismissing Open dlog before doc actually opens
  • Previous by thread: Re: Block gets NULL-ified when animation completes
  • Next by thread: Re: Block gets NULL-ified when animation completes
  • Index(es):
    • Date
    • Thread