Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial
Arsene Lavaux
4,342 PointsWarning on self.imagePicker.delegate = self;
Hi: I am new to iOS dev, beginner developer overall.
Working on the Ribbit app. Got to the CameraViewController class to capture image and video.
I get the following warning: "Assigning to 'id<UINavigationController Delegate,UIImagePickerControllerDelegate>' from incompatible type 'CameraViewController 'const_strong'
on this line of code: self.imagePicker.delegate = self;
How do I make this warning go away?
Thanks! Arsene
5 Answers
Stone Preston
42,016 Pointsyou need to conform to the UIImagePickerDelegate AND UINavigationControllerDelegate protocol by putting
<UIImagePickerControllerDelegate, UINavigationControllerDelegate>
after the name of your class in your .h file. Your class probably already conforms to several delegate protocols so you just need to add a comma and then add them to the list.
should be something like this
@interface TheNameOfYourClass : UIViewController <SomeDelegate, SomeOtherDelegate, UIImagePickerControllerDelegate, UINavigationControllerDelegate>
Arsene Lavaux
4,342 PointsHi Stone,
Thanks again for your help on this. Nonetheless, it looks like I already have this line in the header file:
import <UIKit/UIKit.h>
import <Parse/Parse.h>
@interface CameraViewController : UITableViewController <UIImagePickerControllerDelegate, UINavigationBarDelegate>
If you have any other ideas, feel free to share.
Thanks! Arsene
Stone Preston
42,016 Pointslooks like the code isnt showing up well. see the markdown cheatsheet as to how to format it for the forum.
Arsene Lavaux
4,342 PointsMay I ask where to find this cheatsheet?
Stone Preston
42,016 PointsWhenever you go to type a new answer/comment, there is a link below the text box that says markdown cheatsheet
Arsene Lavaux
4,342 PointsI see it now...
Let's give it a shot:
Objective C
#import <UIKit/UIKit.h>
#import <Parse/Parse.h>
@interface CameraViewController : UITableViewController <UIImagePickerControllerDelegate, UINavigationBarDelegate>
Stone Preston
42,016 Pointsyou conformed to the UINavigationBar delegate protocol, not UINavigationController it needs to be
<UIImagePickerControllerDelegate, UINavigationControllerDelegate>
Arsene Lavaux
4,342 PointsHi Stone: Thank you very much on your great help.
:) Arsene