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

これらはプロトコルと呼ばれます。対応するメソッドやプロパティがこれらのプロトコルに準拠するクラスによって実装される宣言の正式なリストです。

プロトコルの詳細については、こちらをご覧ください。

于 2013-03-29T23:26:56.057 に答える