Does anyone know the rules for default nib loading of iOS View Controllers? Specifically what naming conventions are supported by -[UIViewController initWithNibName:nil bundle:nil]?
The docs, quoted below, don't seem to indicate any special magic in determining the name. However I have determined that there does appear to be some magic to this.
"If you specify nil for the nibName parameter and do not override the loadView method in your custom subclass, the default view controller behavior is to look for a nib file whose name (without the .nib extension) matches the name of your view controller class. If it finds one, the class name becomes the value of the nibName property, which results in the corresponding nib file being associated with this view controller."
Situation:
Here is the situation I have and the problem I ran into. I am working on a existing project and refactoring some code to integrate multiple code bases.
I have a view controller, HomeViewController, and there is an associated nib, HomeViewController.xib. The VC uses the standard initWithNibName:nil bundle:nil. Prior to integrating with another code base it was working fine, the nib objects were loaded and displayed properly at runtime.
In the other code base, which is being integrated, there is a HomeViewController as well. I renamed it to XXHomeViewController. It was using, and explicitly loading, a nib named HomeView.
Problem:
I ran into an issue where loading HomeViewController was failing. I determined that it was loading the wrong nib file. When I removed HomeView.xib from the target the class would load properly with no errors.
It would appear that XXViewController will load XXView.xib before it will load XXViewController.xib.
What this tells me, is that there is some kind of "magic" in determining the correct nib to load if you do not specify a name. Anyone know of documentation that explains this logic?