1
所以我在我的代碼現在這樣:初始化從筆尖,但僅頁頭[UIViewController中]
UIViewController* ctrl =
[[UIViewController alloc] // i'm alloc'ing a UIViewController...
initWithNibName:@"TheNibName" // But this NIB has, within
// interface builder, a link to "UIViewControllerDERIVATIVE". So really,
// `ctrl` is a UIViewControllerDERIVATIVE instance, not just
// a UIViewController instance.
bundle:nil] ;
我這樣做的原因是它使一個巨大的方便寫一些代碼,推模式對話框..因爲Objective-C不支持<模板>。
我的問題是,這是好嗎?我可以只有[alloc]
a UIViewController
,而真正來自NIB的是UIViewControllerDERIVATIVE
的實例嗎?或者它會在晚些時候把我咬到屁股裏?
是的,我真的發現了這一點,因爲'UIViewControllerDERIVATIVE'中的成員實際上並沒有獲得alloc'd。 – bobobobo 2010-05-19 14:24:53