"Build a Vending Machine App in Swift" was retired on May 31, 2020.

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

iOS

Warning 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

you 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>

Hi 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

looks like the code isnt showing up well. see the markdown cheatsheet as to how to format it for the forum.

May I ask where to find this cheatsheet?

Whenever you go to type a new answer/comment, there is a link below the text box that says markdown cheatsheet

I see it now...

Let's give it a shot:

Objective C

#import <UIKit/UIKit.h>

#import <Parse/Parse.h>

@interface CameraViewController : UITableViewController <UIImagePickerControllerDelegate, UINavigationBarDelegate>

you conformed to the UINavigationBar delegate protocol, not UINavigationController it needs to be

<UIImagePickerControllerDelegate, UINavigationControllerDelegate>

Hi Stone: Thank you very much on your great help.

:) Arsene