开发者

Which class will be instantiated

Say I have 2 subclasses from UIViewController, class A and class B. In Main nib file an object is representing class A and it is set to load file from Secondary nib file. The owner of Secondary nib is of class B.

The question is - from which class an object开发者_StackOverflow中文版 in Main nib file will be instanciated once the nib files unarchived in the memory?

The reason this question arised is that I have to take care myself if such reference to external NIB file present, to ensure that the first nib's object and second nib's owner is same. Please correct me if my statement is wrong.


Interesting question but one you can answer yourself :)

Set breakpoints in your initWithCoder methods for classes A and B - see which breakpoint gets called!

I have a hunch that Main.xib is going to instantiate an instance of A. Then Secondary.xib will treat your instance of A as an instance of B and it will crash horribly. But I'm not 100% sure ;)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜