PDA

View Full Version : picker.delegate = self;




rahul29tech
Feb 18, 2012, 04:46 AM
picker.delegate = self;
plz explain me this line of code,,,,,is it necessary to allocate self to delegate what this code actually doing ,whats its necessity ,,,,



ChristianJapan
Feb 18, 2012, 05:07 AM
A bit more context possible ? where did you saw that line ?

Let's assume in this context ...

https://developer.apple.com/library/ios/ipad/#documentation/uikit/reference/UIPickerViewDelegate_Protocol/Reference/UIPickerViewDelegate.html

The protocol just define the methods and is not a class definition whch can be used to initiate an instance. The protocol need to be referenced and implemented by a delegation class (could be a view controller).

Set the delegate is required so that the instance which implement the protocol (like "callback" methods) for the picker actually can be addressed.