0

I do a custom framework and bundle resources by this tutorial.

There are a storyboard (a ViewController inside) and an image in the bundle resources.

I present the ViewController then crash, if I connected any IBOutlet or IBAction. I am sure every connection of UI object is fine.

I have tried to use xib and it worked perfectly.

Here the error log:

* Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[ setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key goButton.' * First throw call stack: (0x244a391b 0x23c3ee17 0x244a3629 0x24c171f3 0x28d828b7 0x24c296d3 0x28ed3e9b 0x243ed1cb 0x28ed2bd1 0x28d85aa3 0x28b58ffb 0x28a1ea1f 0x28a1e971 0x292b3ec1 0x28d6ad01 0x28d8e6e5 0x28d90d25 0x28d90f91 0x28b17db9 0xd0b5 0x28a3714b 0x28aa7193 0x28aa7129 0x28cc75b1 0x28cd37db 0x24465d21 0x244657dd 0x24463d51 0x243b3229 0x243b3015 0x259a3ac9 0x28a87189 0xd2ed 0x2405b873) libc++abi.dylib: terminating with uncaught exception of type NSException

There is a warning before the error:

Unknown class TestViewController in Interface Builder file.

Here is the code I present viewcontroller from a stroyboard of bundle resources.

NSString *bundlePath = [[NSBundle mainBundle] pathForResource:@"XXXSDK" ofType:@"bundle"];
NSBundle *resourcesBundle = [NSBundle bundleWithPath:bundlePath];

UIStoryboard *resourcesStoryboard = [UIStoryboard storyboardWithName:@"Resources" bundle:resourcesBundle];
TestViewController *testVC = [resourcesStoryboard instantiateViewControllerWithIdentifier:@"TestViewController"];

[self presentViewController:testVC animated:YES completion:nil];
Dheeraj D
  • 4,386
  • 4
  • 20
  • 34
ovo
  • 1,904
  • 13
  • 26

3 Answers3

3

With respect to warning you got:

Unknown class TestViewController in Interface Builder file.

There are two possibilities:

  1. It seems that you have not specified class to your NIB/Storyboard ViewController.Please check the issue.
  2. You have your TestViewController.h and TestViewController.m file added in your project. But somehow your files may get deleted from it from Finder.
    If so then you can see your both the file in ProjectNavigator of xCode in your project with RED text color. That means the files compiler expected to have is not added in your project.

Now if you find that you are facing second scenario then go to Trash, select your files, right click and select Put Back.
Then go to your xCode project, right click on your project name and select Add File to "Your Project Name".
I hope this will solve your issue.

Er. Vihar
  • 1,495
  • 1
  • 15
  • 29
1

thank @Er. Vihar's reply.

The solve of my problem, to add the -all_load -ObjC flags to the Other Linker Flags.

ovo
  • 1,904
  • 13
  • 26
0

From this statement: this class is not key value coding-compliant for the key goButton make sure that your goButton is in your class properly. Check your storyboard View controller, whether it has right class associated with it or not.

You may have a bad connection in your xib.

I've had this error many times. Another common cause is when you change the name of a IBOutlet property in your .h/.m which you've already connected up to File's Owner in the nib.

From your nib:

Select the object in IB and go to the 'Connections Inspector'. Under 'Referencing Outlets' make sure that your object isn't still connected to the old property name... if it is, click the small 'x' to delete the reference and build again.

enter image description here

Another common cause if you are using Storyboard, your UIButton might have more then one assignings (Solution is almost the same as for nib):

Open your storyboard and right click the UIButton You will see that there is more than one assign/ref to this button. Remove one of the "Main..." greyed windows with the small "x":

enter image description here

Sivajee Battina
  • 4,124
  • 2
  • 22
  • 45