How are .xib, * .m and * .h files related?

How / where in the code is the nib file associated with its .m and * .h files?

In particular, I'm talking about when you create a new Objective-C class without using a method initWithNibName.

Whenever this relationship is defined, it is obviously used by the File Owner relationships in Interface Builder. I imagine this is a * .plist file somewhere or something.

+3
source share
3 answers

NIB files describe instances of classes.

When you drag a component into the NIB using Interface Builder, you are actually creating an instance.

, , UIViewController, UIViewController OWN- .m .h, : " UIViewController ".

Tools/Identity Inspector, : , .h .m

+5

NIB . XIB. XIB - (, XML), NIB - . XIB Interface Builder, NIB .

.h . Builder , Objective C , , . XIB, ViewController . Interface Builder .h / .

.m . Builder. , NIB. , , .

+3

, , , ...

, :

MyViewController *controller = [[MyViewController alloc] initWithNibName:@"MyView" bundle:nil];

"MyView.xib" MyViewController. MyViewController XIB.

xib - , xib. - , , .

Please note that this means that you can have multiple xib files that use the same view controller if you want the same controller to have different screens. You don't often do this often, but if used properly, it can be powerful (it can also be a mess if you try to make one view controller that does too many things).

0
source

Source: https://habr.com/ru/post/1736720/


All Articles