Warning message in takePicture:


#1

I have a warning in my takePicture: method that I don’t understand. My code is provided below. The warning is with setting the Delegate to self. The warning is: Sending ‘DetailViewController *const __strong’ to parameter of incompatible type ‘id<UINavigationControllerDelegate,UIImagePickerControllerDelegate>’

The project runs correctly. I didn’t see anything in the book about this warning. Does anyone else have this warning or know how to eliminate it? Thanks.

[code]- (IBAction)takePicture:(id)sender
{
UIImagePickerController *imagePicker = [[UIImagePickerController alloc] init];
if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]){
[imagePicker setSourceType:UIImagePickerControllerSourceTypeCamera];
} else {
[imagePicker setSourceType:UIImagePickerControllerSourceTypePhotoLibrary];
}
[imagePicker setDelegate:self];

[self presentViewController:imagePicker animated:YES completion:nil];

}[/code]


#2

Make sure that your class conforms to these protocols: UINavigationControllerDelegate and UIImagePickerControllerDelegate:

// FooViewController.m
...
@interface FooViewController () <UINavigationControllerDelegate, UIImagePickerControllerDelegate>
@end

@implementation FooViewController
...
@end

#3

Thanks! I thought I was, but when I went back and checked, I had accepted UINavigationBarDelegate rather than UINavigationControllerDelegate from the XCode’s code completion.