從nib文件,創(chuàng)建實(shí)例,并不是創(chuàng)建"一個(gè)"實(shí)例,而是方框中拖進(jìn)去的各個(gè)實(shí)例,這些實(shí)例有的是UIView類(lèi)型,有的是UIControl類(lèi)型,有的是UIViewController類(lèi)型,有的是NSObject類(lèi)型。
- (nullable NSArray *)loadNibNamed:(NSString *)name
owner:(nullable id)owner
options:(nullable NSDictionary *)options;
所用這些實(shí)例,隨著nib文件的解檔而被喚醒賦予鮮活的生命,保存到被nib文件加載函數(shù)的數(shù)組類(lèi)型的返回值中。
An array containing the top-level objects in the nib file. The array does not contain references to the File’s Owner or any proxy objects; it contains only those objects that were instantiated when the nib file was unarchived. You should retain either the returned array or the objects it contains manually to prevent the nib file objects from being released prematurely.
1、IBFilesOwner不會(huì)分配內(nèi)存實(shí)例,IBFirstResponder不會(huì)分配內(nèi)存實(shí)例,通過(guò)owner關(guān)聯(lián),以后的連線(xiàn)既是對(duì)owner的動(dòng)態(tài)運(yùn)行是的綁定kvc設(shè)置成員、方法(即iboutlet,ibaction)。
2、非UIView/UIControl的類(lèi)型,會(huì)分配內(nèi)存實(shí)例。可以通過(guò)連線(xiàn),可以作為本nib文件內(nèi)任何其它實(shí)例的outlet、outletcollections
注意:External object并不會(huì)分配內(nèi)存實(shí)例。
3、UIView/UIControl類(lèi)型,會(huì)分配內(nèi)存實(shí)例??梢赃B線(xiàn),添加其它的iboutlet,也可以做IBFilesOwner的iboutlet
可以通過(guò)連線(xiàn),成員屬性、成員方法
iboutlet
iboutlet collection
ibaction
上面的2,3,可以作為filesowner的outlet
上面的2可以作為filesowner的outlet,也可以作為3的customClass類(lèi)的實(shí)例的outlet
上面的3的子views可以作為它的實(shí)例的outlet