Do Nib files automatically initialize certain properties?
In most objective-c code I’ve seen, you initialize a pointer with:
MyObject* obj = [MyObject alloc];
[MyObject doStuff];
[obj release];
However, with certain objects (like ViewController Subclasses) UIView objects are used without being initialized, and aren’t ever released. Does UIKit automatically look for a .xib file and manage all of the ViewController instances for you?
If so, that is extremely confusing. How does all of this actually work? How can you declare a pointer in a header file, and then magically find it allocated when you need it?
Any help?
(Just a c++ guy complaining about objective-c)
NIBs are ‘frozen’ objects, plus the object graph. The objects are instantiated when the NIB is loaded. All links between objects are restored. Also set are pointers in the “Files Owner”, the IBOutlets, so the Owner of the NIB has references to the objects just loaded.
Edit: your Info.plist may also refer to a “main” NIB which’ll get loaded during app launch. This often contains the main view controllers & views.