开发者

What Objective C preprocessor / Compiler / Iphone SDK do behind the scene?

I do see tutorials like this one http://www.youtube.com/watch?v=8X-vDtEwpeo

They're good but they just describe the recipe so I still don't understand the logics what's happening behind the scene:

What Objective C preprocessor / Compi开发者_运维知识库ler / Iphone SDK do when one drag from Interface Builder to Fileowner. Why this name "file owner" ?


Consider what you might do if you were creating, say, a UIView subclass programmatically.

In the subclass init method in some .m file, you might alloc a button.

Then you would assign that button to an instance variable in your inited object via some property setter.

Then you might add a method in that class file as the selector to handle that button's control event.

Interface builder is trying to save the information required for the runtime to do all of that for you in a compressed object representation (the xib file).

The SDK and/or preprocessor provides Interface Builder with a list of your specially marked instance variables and methods inside the .h and .m files.

The file owner tells IB which class name in your .m and .h files to look for and use for that xib file.

The IBOutlets that you drag tell the runtime which property assignments to make in that class.

The IBActions that you drag tell the runtime which selectors to set for various control actions in that class.


The file owner is the instance that load the xib. That's why it is called file owner. It is the runtime that links the deserialized objects to the owner.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜