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
Objective-C allows you to define protocols, which declare the methods expected to be used for a particular situation. This chapter describes the syntax to define a formal protocol, and explains how to mark a class interface as conforming to a protocol, which means that the class must implement the required methods.
An Objective-C delegate is an object that has been assigned to the delegate property another object. To create one, you define a class that implements the delegate methods you're interested in, and mark that class as implementing the delegate protocol.
Delegates are a use of the language feature of protocols. The delegation design pattern is a way of designing your code to use protocols where necessary. In the Cocoa frameworks, the delegate design pattern is used to specify an instance of a class which conforms to a particular protocol.
Just separate them by a comma: <MPMediaPickerControllerDelegate, UITextFieldDelegate>
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 >
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