Alex
Alex

Reputation: 1042

Can you use a view controller created for a xib with storyboards?

We have a framework that we generally use with our iOS projects that includes all of our login information and stuff like that. It was created before iOS5 and therefore did not use storyboards. We are now planning to move into storyboards. I created the initial view Controller, exactly like the xib in another project. Then I set the view controller in the Identity Inspector and hooked in all of the outlets and actions from the Connections Inspector. However, when I run the project, I get the following error:

2012-09-14 08:46:15.366 Mixable[3923:f803] Unknown class LoginViewController in Interface Builder file.
2012-09-14 08:46:15.460 Mixable[3923:f803] *** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<UIViewController 0x6851200> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key loginBtnFacebook.'
*** First throw call stack:
(0x14b1022 0xeb1cd6 0x14b0ee1 0x9c2022 0x933f6b 0x933edb 0x94ed50 0x23671a 0x14b2dea 0x141c7f1 0x23526e 0xdb1fc 0xdb779 0xdb99b 0x3a401 0x3a670 0x3a836 0x4172a 0x12596 0x13274 0x22183 0x22c38 0x16634 0x139bef5 0x1485195 0x13e9ff2 0x13e88da 0x13e7d84 0x13e7c9b 0x12c65 0x14626 0x201d 0x1f85 0x1)
terminate called throwing an exception

and if I remove the connection to the loginBtnFacebook, I just get it for the next outlet that I have hooked up, and that continues until I remove all outlets.

Is it possible to use the same View Controllers or will we need to rewrite all of them?

Upvotes: 0

Views: 222

Answers (1)

Rob
Rob

Reputation: 437562

In answer to your question, the view controllers are largely the same (except which init methods are used, e.g. you obviously don't use initWithNibNamed with storyboards, but this seems unrelated to your problem here).

So, a couple of questions related to your error, which is the typical symptom of outlet linking issues:

  1. Have you configured your scene's view controller class? Click on the view controller button at the bottom of the scene, click on on the "Identity inspector" tab button at the top of the right panel, and make sure you specify your view controller class.

  2. Are you IBOutlet's hooked up correctly? When you click on the "Assistant Editor" in the right side of the toolbar, you should see the .h file for your class show up at the bottom. Do you have solid black dots next to the IBOutlet definitions ensuring that everything is hooked up?

    IBOutlet linkage confirmation screen snapshot

  3. This is unlikely to be the issue, but have you included the view controller's .m file in the "Compile Sources" section of "Build Phases"?

    Compile sources

Upvotes: 1

Related Questions