2

Some code I am using uses the deprecated method dismissModalViewControllerAnimated. The docs say to use dismissViewControllerAnimated:completion: now. I am unsure about the completion: part. In my case should the completion be nil or NULL or what?

Original code is as follows.

- (void)didFinishWithCamera
{
    [self dismissModalViewControllerAnimated:YES];

    if ([self.capturedImages count] > 0)
    {
        if ([self.capturedImages count] == 1)
        {
            // we took a single shot
            [self.imageView setImage:[self.capturedImages objectAtIndex:0]];
        }
        else
        {
            // we took multiple shots, use the list of images for animation
            self.imageView.animationImages = self.capturedImages;

            if (self.capturedImages.count > 0)
                // we are done with the image list until next time
                [self.capturedImages removeAllObjects];

            self.imageView.animationDuration = 5.0;    // show each captured photo for 5 seconds
            self.imageView.animationRepeatCount = 0;   // animate forever (show all photos)
            [self.imageView startAnimating];
        }
    }
}
zerowords
  • 2,915
  • 4
  • 29
  • 44

1 Answers1

2

If you don't care about completion, then provide an empty block:

[self dismissModalViewControllerAnimated:YES
                              completion:^(void){}];
trojanfoe
  • 120,358
  • 21
  • 212
  • 242
  • So nil isn't okay? I thought a nil completion is fine. – Warren P Feb 23 '13 at 15:17
  • @WarrenP Actually, `nil` does appear to be OK: http://stackoverflow.com/questions/12445190/dismissmodalviewcontrolleranimated-deprecated – trojanfoe Feb 23 '13 at 15:20
  • In which case, not emitting an empty completion would be preferable, and nil would always and everywhere be better. Oh and less typing of punctuation characters. – Warren P Feb 23 '13 at 15:21