• 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
Block gets NULL-ified when animation completes
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Follow-Ups:
    • Re: Block gets NULL-ified when animation completes
      • From: Andreas Grosam <email@hidden>
    • Re: Block gets NULL-ified when animation completes
      • From: Jens Alfke <email@hidden>
  • Prev by Date: NSSpellChecker -ignoreWord:… for NSTextCheckingTypeGrammar?
  • Next by Date: Re: Block gets NULL-ified when animation completes
  • Previous by thread: Re: NSSpellChecker -ignoreWord:… for NSTextCheckingTypeGrammar?
  • Next by thread: Re: Block gets NULL-ified when animation completes
  • Index(es):
    • Date
    • Thread