1

In my app I have a UIViewController and a UIView named

  • HomeViewController
  • HomeView

They are both being loaded from a nib and the nib files are named the same as the class names When I try to initialize my ViewController:

HomeViewController *h = [[HomeViewController alloc] init];

It tries to load the viewController using the nib file for my UIView instead of the nib for my ViewController, If i load using initWithNibNamed it works fine.

Is this a bug in iOS I have never had this problem before. I am running against iOS 5 beta 5

0

1 Answer 1

2

It is the way that you are naming your view and viewcontroller which is causing the problem. From Apple's documentation (look at the nibName property)

  1. If the view controller class name ends with the word “Controller”, as in MyViewController, it looks for a nib file whose name matches the class name without the word “Controller”, as in MyView.nib.

  2. It looks for a nib file whose name matches the name of the view controller class. For example, if the class name is MyViewController, it looks for a MyViewController.nib file.

If you changed the HomeView to MyHomeView for example, your code will start working again. BUT using initWithNibName: method is the recommended way for initializing a ViewController

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.