I am trying to add an UIImagePickerController and i get an incompatible type 'id<UINavigationControllerDelegate,UIImagePickerControllerDelegate>' compiler warning. I need to know why? and a solution for it.
.m
imagePicker = [[UIImagePickerController alloc] init];
[imagePicker setDelegate:self];
.h
@interface GobblesViewController : UIViewController <UIImagePickerControllerDelegate>
{
UIImagePickerController *imagePicker;
}
@property (nonatomic,strong)UIImagePickerController *imagePicker;

The warning point to [imagePicker setDelegate:self]; and i have no clue why this is occurring.
You're getting this warning because the object, self in this case, that you're passing in to UIImagePickerController's delegate property, doesn't conform to the UIImagePickerControllerDelegate and UINavigationControllerDelegate protocols. This is because UIImagePickerController is a subclass of UINavigationController which already declares it's own delegate.
The delegate property on UIImagePickerController is defined as:
@property (nonatomic, assign) id <UINavigationControllerDelegate, UIImagePickerControllerDelegate> delegate;
Which means it is anticipating any object that conforms to those two protocols.
The @interface declaration for your class should be...
@interface GobblesViewController : UIViewController <UIImagePickerControllerDelegate, UINavigationControllerDelegate>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With