Completion Block in drawHypnoticMessage:


On page 496, when I update the completion block to log the “Animation Finished” message to the console, I never see the message.

The animation appears to work fine, but I’m seeing no message. The code I have is

[code] [UIView animateKeyframesWithDuration:1.0 delay:0.0 options:0 animations:^{
[UIView addKeyframeWithRelativeStartTime:0 relativeDuration:0.8 animations:^{ =;

        [UIView addKeyframeWithRelativeStartTime:0.8 relativeDuration:0.2 animations:^{
            int x = arc4random() % width;
            int y = arc4random() % height;
   = CGPointMake(x,y);
    } completion:^(BOOL finished) {
          NSLog(@"Animation finished");

I’m sure I’m missing something obvious (typo, method name autocomplete etc.), but staring at the code hasn’t revealed any answers.

All thoughts welcomed.


If you are suspecting that the completion block is not firing because you can’t see the log, you can use an assert statement to debug:

        } completion:^(BOOL finished) {
              // crash if we get here because I can't see my log!
              assert (0);
              NSLog (@"Animation finished");


Thanks for the suggestion.

I added the assert prior to the NSLog statement, and it does fire - so the completion block is being triggered. So then moved the assert to after the NSLog statement, and it also fires (but the output is still not logged to the console). So either something weird is happening or I’m overlooking something super obvious.

It’s not a huge deal in the grand scheme of things, but I know it’s going to niggle my brain until I work it out.


Aha! I knew if it was a choice between a weird bug or me doing something stupid, there was more chance of it being my fault.

Somehow, I had accidentally set the console output to be “Debugger Output” instead of “All Output”. Switched it back and the NSLog, not surprisingly, works just fine.


Glad you got it! Thanks for posting the solution!