teepusink
teepusink

Reputation: 28922

Objective-C double Delegate protocol

I get the following error when compiling my app.

warning: class 'ConfigureViewController' does not implement the 'MPMediaPickerControllerDelegate' protocol

I know that it means I have to implement the delegate in the Controller. i.e @interface ConfigureViewController : UIViewController <MPMediaPickerControllerDelegate>

However, my current controller already has a delegate implementation for <UITextFieldDelegate> i.e @interface ConfigureViewController : UIViewController <UITextFieldDelegate>

How do I go around this issue?

Thanks, Tee

Upvotes: 18

Views: 8321

Answers (2)

Greg Martin
Greg Martin

Reputation: 5064

Just separate them by a comma: <MPMediaPickerControllerDelegate, UITextFieldDelegate>

Upvotes: 47

coobird
coobird

Reputation: 161022

One can implement multiple protocols by specifying multiple protocols in the class declaration.

In this case, in order to implement both MPMediaPickerControllerDelegate and UITextFieldDelegate, the class declaration would be:

@interface ConfigureViewController : UIViewController < UITextFieldDelegate, MPMediaPickerControllerDelegate >

Upvotes: 13

Related Questions