views:

21

answers:

1

I have been doing a lot of work on UIViewControlers and Nibs and notice there are two ways of doing it.

@class AController : UIViewController

[[AController alloc] initWithNibName:<name of nib> bundle:nil];

and the other way is that you make the File Owner the the UIViewController and link the View. All you have then do is

[[AController alloc] init];

or have it done else where, like in other nib files (I think). For me, the latter is so much easier, so when explain how to load a nib file, why do they always use the first? And is there any difference, like performance-wise?

+1  A: 

init is just a convenience method that will load nib based on view-controller's name. If you provide the same name to initWithNibName:bundle:, then it is absolutely the same. There is practically no performance difference.

Michal
I don't name my nibs with the same name as the view controller, but it's good to know there is not performance difference.
kuroutadori
It's a good practice to name them the same way, it's easier to navigate the project then.
Michal