Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How does loadNibNamed?

In most of the samples the return value from loadNibNamed value is not used, so I guess it's using the owner argument. But how does it work and make the connection to the owner object? What kind of requirements should my owner class meet in order to load a nib in such way?

The only requirements I can guess is that

  1. the owner class must have an outlet defined on or many of the objects in the nib file
  2. the nib file's owner SHOULD be set to the class where the nib is being loaded, then the owner param in loadNibNamed can be set to self
  3. the nib file should have all connections set to outlets defined in owner class

Am I right in my assumptions or is there anything else I have to consider while using loadNibNamed?

like image 615
Pablo Avatar asked Jun 20 '10 02:06

Pablo


1 Answers

You have a basic understanding of what is required, though you should also consider memory management (which is slightly different for iPhone versus Mac). To really understand what is going on with this method, you should read the Nib Files section of the Resources Programming Guide. It covers the actual methods used to make the connections (which can be important), and the retain counts that various objects will have when it is done. Again, these are all slightly different between Mac and iPhone. iPhone has generally improved the consistency of how nib objects are handled.

For good measure, I always recommend that people read Memory Management of Nib Objects from the Memory Management Programming Guide. It's critical reading whether you use the lower-level methods or not.

like image 87
Rob Napier Avatar answered Sep 22 '22 17:09

Rob Napier