The code:
UIImagePickerController *picker = [[UIImagePickerController alloc] init];
picker.delegate = self;
picker.sourceType = UIImagePickerControllerSourceTypeCamera;
[self.navigationController presentModalViewController:picker animated:YES];
[picker release];
The warning, which shows up on the picker.delegate = self; line:
Class 'CardEditor' does not implement the 'UINavigationControllerDelegate' protocol
Why does the UIImagePickerController care if my class implements the UINavigationControllerDelegate protocol?
UIImagePickerControllerinherits fromUINavigationController. The delegate property is part ofUINavigationController, so it requires that its delegate conforms to theUINavigationControllerDelegateprotocol.The delegate property is declared like so:
This tells the compiler to verify that your controller will implement the
UINavigationConrollerDelegateprotocol. The check is in place so that a compile-time warning can be generated if your controller class does not properly implement all of the methods that theUINavigationControllermight send to its delegate.If you’re looking for a solution, you can indicate (in your controller class interface) that your controller is compliant with that protocol:
Once this is done, the compiler will warn you about any required delegate methods that you haven’t implemented. This is a good thing, as it will prevent you from releasing code that might accidentally throw a “method not found” runtime error.