07/07/10

How to programatically load nib files

Filed under: iPhone Dev SDK by Marc @ 15:49

A few days ago I was asked if it’s possible to load nib files programatically without being loaded and initialized from UIViewController’s initWithNib… message.

I didn’t knew the answer at this moment but once I got to the office I decided to look for it. After a few minutes googling I found the answer: it’s possible, and here is the source code to do it.

NSArray *topLevelObjs = nil;
topLevelObjs = [[NSBundle mainBundle] loadNibNamed:nibNameOrNil owner:self options:nil];

if (topLevelObjs == nil)
   NSLog(@”Error! Could not load nib file.\n”);



No Comments

No comments yet.

RSS feed for comments on this post. TrackBack URL

Sorry, the comment form is closed at this time.