0

I am a newbie to objective C. I was looking through a few tutorials online to create like a dropdown using the iOS sdk. So I came across the picker view, and from a few online resources I came to know that I would have to provide a delegate and a datasource for the picker.

And the syntax in the header file for the interface is something like this.

@interface ViewController : UIController <UIPickerViewDataSource, UIPickerViewDelegate>

@end

Now, I understand that UIController is the parent of ViewController, but what does the greater than & less than mean here?

4

2 回答 2

5

<UIPickerViewDataSource, UIPickerViewDelegate> means that the class conforms to these two protocols. Protocols are akin to interfaces in C# and Java✝</sup>; they describe a list of methods you must implement in your class. Your class, ViewController, must implement all methods that are required by the UIPickerViewDataSource and UIPickerViewDelegate protocols.

See Working with Protocols, UIPickerViewDataSource Protocol Reference and UIPickerViewDelegate Protocol Reference.

✝ With the slight difference that methods in protocols can be marked as optional, whereas methods in interfaces are always required.

于 2013-03-29T23:25:46.743 回答
1

Those are called protocols: formal lists of declarations for which the corresponding methods and/or properties are to be implemented by the class that conforms to these protocols.

More about protocols here.

于 2013-03-29T23:26:56.057 回答