1

setCompletionHandler method from NSAnimationContext is not working for me. I am using code form Apple's documentation:

    [NSAnimationContext setCompletionHandler:^{
   // This block will be invoked when all of the animations
   //  started below have completed or been cancelled.
    NSLog(@"All done!");

And I have the following error: No known class method for selector 'setCompletionHandler:'

When I look into NSAnimationContext.h file next to this method there is #if NS_BLOCKS_AVAILABLE and NS_AVAILABLE_MAC(10_7). My deployment target is "10.7", however I do not know how can I check if NSBlocks are available. Or maybe the problem lies in other thing?

Tulon
  • 4,011
  • 6
  • 36
  • 56
Wojtek
  • 1,006
  • 11
  • 30

1 Answers1

2

The example code in the documentation has an error. The -setCompletionHandler: method is an instance method, not a class method. You need to invoke it on [NSAnimationContext currentContext], not on the class itself:

[[NSAnimationContext currentContext] setCompletionHandler:^{
   // This block will be invoked when all of the animations
   //  started below have completed or been cancelled.
    NSLog(@"All done!");
}];
Ken Thomases
  • 88,520
  • 7
  • 116
  • 154