When you link an object to an IBOutlet, what method of the class does it use to create the inst开发者_Go百科ance? Alloc/init?
"during the instantiation process, each object in the archive is unarchived and then initialized with the method befitting its type. Objects that conform to the NSCoding protocol (including all subclasses of UIView and UIViewController) are initialized using their initWithCoder: method. All objects that do not conform to the NSCoding protocol are initialized using their init method. After all objects have been instantiated and initialized, the nib-loading code reestablishes the outlet and action connections for all of those objects. It then calls the awakeFromNib method of the objects. For more detailed information about the steps followed during the nib-loading process, see Nib Files and Cocoa in Resource Programming Guide."
http://developer.apple.com/library/ios/documentation/uikit/reference/NSObject_UIKitAdditions/Introduction/Introduction.html#//apple_ref/occ/instm/NSObject/awakeFromNib
Depends on the object parent class, but usually yes, even if sometimes initWithCoder:
is called instead of the init
method.
You can test it by simply putting a call to NSLog in the init method.
精彩评论