Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Assigning to from incompatible type warning

Assigning to id from incompatible type ''CameraVIewController*'' warning showing at the below code

 UIImagePickerController * picker = [[UIImagePickerController alloc] init];
 picker.delegate = self;
like image 297
susitha Avatar asked Nov 28 '22 03:11

susitha


1 Answers

Actually, I think the real reason is that you miss the protocol "UINavigationControllerDelegate"

in UIImagePickerController.h you can see the delegate define:

@property(nonatomic,assign)    id <UINavigationControllerDelegate, UIImagePickerControllerDelegate> delegate;

So if you want to assign delegate like this:

picker.delegate = self;

the self viewController must implement both UINavigationControllerDelegate and UIImagePickerControllerDelegate

If you only implement UIImagePickerControllerDelegate, you can not find any error literal, but you will get a warning "Assigning to id from incompatible type ''CameraVIewController''*", add UINavigationControllerDelegate to your viewController's protocol declaration shall get rid of it.

It's a very late answer, but I just met and solved it, hope it helps.

like image 144
Jared Chen Avatar answered Dec 09 '22 12:12

Jared Chen