An Error with seting Assetlibrary.framwork [duplicate] - iphone

I'm trying to link a UILabel with an IBOutlet created in my class.
My application is crashing with the following error.
What does this mean?
How can I fix it?
*** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<UIViewController 0x6e36ae0> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key XXX.'

You may have a bad connection in your xib.
I've had this error many times. While TechZen's answer is absolutely right in this case, 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.
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":

Your view controller may have the wrong class in your xib.
I downloaded your project.
The error you are getting is
'NSUnknownKeyException', reason: '[<UIViewController 0x3927310> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key string.'
It is caused by the Second view controller in MainWindow.xib having a class of UIViewController instead of SecondView. Changing to the correct class resolves the problem.
By the way, it is bad practice to have names like "string" in Objective-C. It invites a runtime naming collision. Avoid them even in once off practice apps. Naming collisions can be very hard to track down and you don't want to waste the time.
Another possible reason for this error: when copying & pasting elements from one controller into another, Xcode somehow keeps that link to the original controller, even after editing & relinking this element into the new controller.
Another possible reason for this error:
Bad Outlet.
You have either removed or renamed an outlet name in your .h file.
Remove it in .xib or .storyboard file's Connection Inspector.
One more possible reason
(In my case) Extension of UIView with bindable properties and setting values for those bindable properties (i.e. shadow, corner radius etc.) then remove those properties from UIView extension (for some reason) but the following <userDefinedRuntimeAttributes> remained in xml (of foo.storyboard):
<userDefinedRuntimeAttributes>
<userDefinedRuntimeAttribute type="color" keyPath="shadowColor">
<color key="value" white="0.0" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
</userDefinedRuntimeAttribute>
<userDefinedRuntimeAttribute type="number" keyPath="shadowOpacity">
<real key="value" value="50"/>
</userDefinedRuntimeAttribute>
<userDefinedRuntimeAttribute type="point" keyPath="shadowOffset">
<point key="value" x="5" y="5"/>
</userDefinedRuntimeAttribute>
<userDefinedRuntimeAttribute type="number" keyPath="shadowRadius">
<real key="value" value="16"/>
</userDefinedRuntimeAttribute>
<userDefinedRuntimeAttribute type="number" keyPath="borderWidthValue">
<real key="value" value="0.0"/>
</userDefinedRuntimeAttribute>
</userDefinedRuntimeAttributes>
Solution: Right click on foo.storyboard > Open as Source Code > search by keyPath (i.e. shadowRadius) > Delete the </userDefinedRuntimeAttributes> that causing the problem

Sometimes this has to do with your "Inherit From Target" That value has to be set. With single target apps you can just select Inherit From Target. If you have more then one target select the desired target.

I had this error when I was trying to implement a custom ViewCell for a table. When I highlighted View controller for the XIB and connected to the elements in the CellView caused the error " this class is not key value coding-compliant for the key" once I deleted these it got rid of the error.
Delete the connections in the below image.
Just make sure that you only have the connections with the Table View Cell. To check click on table view cell and in INSPECTOR look for your connections.

I had to delete the app from the simulator/iPhone to get rid of this error.

If it is an iPhone only app, not a universal one, make sure the following field is empty:
Targets > Summary > iPhone/iPod Deployment Info > Main Interface
If you specify an xib there it crashes.

This error indicates that an already connected Interface Builder object is removed/renamed in its owner's source (File's Owner).
Control-click on the Files's Owner in the Interface Builder if you see a exclamation mark you need to fix that.
In the picture below you can see that "aRemovedView" has an exclamation mark on its right, that's because I removed the IBOutlet view object while it was already connected in the IB.
This gives the following error:
Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[ setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key aRemovedView.'

I had the same problem and while TechZen's answer may indeed be amazing I found it hard to apply to my situation.
Eventually I resolved the issue by linking the label via the Controller listed under Objects (highlighted in the image below) rather then via the File Owner.
Hope this helps.

in my case it was an error in the storyboard source code, follow these steps:
first open your story board as source code
search for <connections>
remove unwanted connections
For example:
<connections>
<outlet property="mapPostsView" destination="4EV-NK-Bhn" id="ubM-Z6-mwl"/>
<outlet property="mapView" destination="kx6-TV-oQg" id="4wY-jv-Ih6"/>
<outlet property="sidebarButton" destination="6UH-BZ-60q" id="8Yz-5G-HpY"/>
</connections>
As you see, these are connections between your code variables' names and the storyboard layout xml tags ;)

My fix was similar to Gerard Grundy's. In creating a custom UITableViewCell using an XIB, I had mistakenly applied the Custom Class name to the File's Owner instead of to the UITableViewCell. Applying the class to the UITableViewCell on the canvas and connecting my IBOutlet properties to it solved the issue.

You only need to specify IBOutlet once, the IBOutlet label your ivar is unnecessary.
Are you instantiating your NIB using your UIViewController? At some point you should be calling [SecondView initWithNibName:#"yourNibName" bundle:nil];

This was happening to me only when debugging on a device (iPhone). The iOS Simulator was working OK. Doing a "Product->Clean" from Xcode seemed to solve the problem, but I have no idea why.

I had exact same error message and thanks (!!) to Kira from http://www.idev101.com I was able to solve the challenge. I only found her site after googling and stacking over all these threads. I'm now posting here for the next one that comes to StackOverFlow and has the same challenge I had since that person will most likely come to this thread over Google.
I realized, that I wrongly made this:
UIViewController *deviceViewController = [[UIViewController alloc] initWithNibName:#"DeviceViewController" bundle:nil];
Instead of THIS:
DeviceViewController *deviceViewController = [[DeviceViewController alloc] initWithNibName:#"DeviceViewController" bundle:nil];
Where
DeviceViewController
Was the name of my Class also known as
DeviceViewController.h
DeviceViewController.m
You'll have to
"import DeviceViewController.h"
in your implementation (.m File) where you want to call e.g. another UIViewController.
I am absolutely not sorry if I am only stating the obvious for beginners like me and may get down votes as this is not exactly related to the question but I was searching 4 (?!?) hours straight now for the answer to these error message. If I can spare this to 1 or 2 people that'd be great :)
PS: For those interested in how the code continues for loading the other UIViewController:
[self presentViewController:deviceViewController animated:YES completion:nil];

It can come from the fact that you have control dragged and created an outlet or action, and forgot to delete it. Even if you deleted the code, or even if you have made enough cmd+Z, you'll need to go in the connection inspector of your storyboard and see if the action or outlet you created is still here or not.

Looking over the other answers it seems like there are a lot of things that can cause this error. Here is one more.
If you
have a custom view
added an #IBInspectable property
and then later deleted it
Then you may also get an error similar to
Failed to set (xxx) user defined inspected property on [Your Custom
View] ...: this class is not key value coding-compliant for the key
[xxx].
The solution is to delete the the old property.
Open the Identity inspector for your class, select the property name under User Defined Runtime Attributes, and press the minus button (-).

This happens to me when my view controller originally had an .xib file, but now is created programmatically.
Even though I have deleted the .xib file from this project. The users iPhone/iPad may contain an .xib files for this viewcontroller.
Attempting to load an .xib file usually causes this crash:
Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<UIViewController 0x18afe0> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key welcomeLabel.'
Solution when creating it programmatically may be this:
-(void)loadView {
// Ensure that we don't load an .xib file for this viewcontroller
self.view = [UIView new];
}

"Module" property of View Controller in the Identity Inspector might be different than what you expected. Also make sure that new classes are added to your target list.

I had a similar problem for a project that has two targets (with their own MainWindow XIB). The fundamental issue that caused this error for me was that the UIViewController class wasn't included in the second project's resource list. I.e. interface builder allowed me to specify it in MainWindow.xib, but at runtime the system couldn't locate the class.
I.e. cmd-click on the UIViewController class in question and double-check that it's included in the 'Targets' tab.

Just to add to this, because I was getting this error as well. Going through all these answers most seem to apply to working with the UI and storyboard stuff. I know the original poster did seem to be working with the UI but when searching for possible reasons for this error mostly all questions lead back to this question with those others being closed as duplicates or simply having issues with connecting things in a storyboard so I will add my solution.
I was working on coding a web service in Swift 2. I had built all the needed proxy objects and stubs. As I looped through the returned XML I was dynamically instantiating my objects, which all came from NSObject and using setValue:forKey on them. Every time setValue:forKey tried to set a property it blew up with this error.
I had a switch statement for each type I was dealing with (e.g. Bool?, CShort?, String?) and for each XML node I went through and checked what the type was on the object and then converted the value to that type and attempted to set it with setValue:forKey.
Eventually I started commenting out all these setValue:forKey lines and found that my default switch statement case did work for String?.
I finally figured out that you can't use optional swift types with setValue:forKey unless they have a direct mapping to an Objective-C type like String? or NSNumber?. I ended up changing all CShort? types to NSNumber? since that has a direct mapping. For Bool? in my case it was fine for me to just use Bool and initialize it to false. Others may not have that luxury.
Anyway what a headache that was so hopefully this helps someone else who has a similar problem and keeps getting redirected to this question and saying to themselves, "I am not doing anything in UI!!".
So lastly to reiterate one more time Key-Value Coding does not work with optionals. Below I ended up finding somewhere but I forget where so to whoever posted this I apologize and would give credit if I remembered where I found this but it saved my life:
You cannot use KVC on an Optional Int property, because KVC is Cocoa /
Objective-C, and Objective-C cannot see an Optional Int - it is not
bridged to Objective-C. Objective-C can only see types that are
bridged to Objective-C:
class types that are derived from NSObject
class types that are exposed with #objc
Swift structs that are bridged

"this class is not key value coding-compliant for the key"
I know its a bit late but my answer is different so I thinks it needs to be posted, I was pushing the second controller in wrong way, Here is sample
Wrong Way to Push Controller
UIViewController* controller = [[UIViewController
alloc]initWithNibName:#"TempViewController" bundle:nil];
[self.navigationController pushViewController:controller animated:true];
Correct way
TempViewController* controller = [[TempViewController
alloc]initWithNibName:#"TempViewController" bundle:nil];
[self.navigationController pushViewController:controller animated:true];
I did not found any answer like above so may be it can help some one having same issue

That might be the case of referencing a component from Xib Interface that you have renamed or delete. Re-referencing works for me.

I just had this issue in my duplicated project and solved by checking 2 places:
1- Make sure you have the .m file in the list -> Project - Build Phases - Compile Sources
2- After that, go to interface builder (probably this is an error occures with only IB) and unlink all properties, labels, images, etc... Then re-link all. I have realized that I've removed an attribute but it was still linked in IB.
Hope it works for some.

Another "not compliant" issue I found was when I managed to have two copies of a class for some reason.
I was adding keys to the wrong copy. Interface Builder still saw the keys and let me hook up to them, but at runtime it was using the other copy of the class that didn't have the new keys.
To find which was the "right" copy I used XCode's cmd-click on the class name elsewhere to jump to the correct copy, then I killed off the bad unused copies (after bringing over my edits from the un-used copy first).
Moral of the story: duplicate class files are bad.

This error is something else!
Here is how i Fixed it. I'm using xcode Version 6.1.1 and using swift. I got this error every time my app tried to perform a segue to jump to the next screen. Here what I did.
Checked that the button was connected to the right action.(This wasn't the problem, but still good to check)
Check that the button does not have any additional actions or outlets that you may have created by mistake. (This wasn't the problem, but still good to check)
Check the logs and make sure that all the buttons in the NEXT SCREEN have the correct actions, and if there are any segues, make sure that they have a unique identifier. (This was the problem)
One of the segues did not have a unique identifier
One of the buttons had an action and two outlets that I created by mistake.
Delete any additional outlets and make sure that you the segues to the next screen have unique identifiers.
Cheers,

In my case. I didn't have missing outlets in xib-files after merging.
Shift + Command + K
solved my problem. I cleaned my project and rebuilt.

I had the same symptom. The root cause was that the "Target Membership" for my source file was not set to the correct target. I assume that means my class wouldn't get built and included in my app.
To correct it:
Highlight your .m file.
In the right pane, select the File Inspector.
Under the "Target Membership" section, make sure the appropriate build target is checked.
Hope this helps somebody out there.

If you have a custom UIViewController subclass with IBOutlets that are causing problems the only set of steps I found to actually get rid of the error were
.1 Change the class to UIViewController
.2 Disconnect all the outlets (they will all have the yellow warning triangle now) - it may be enough just to disconnect the problematic outlet(s).
.3 Do all the standard steps - ↑⌘K, delete Derived Data (, prayer mats, worry beads)
.4 Launch the app - go to the problematic scene.
.5 Kill the app, go back to Interface Builder change the class back to your custom class name.
.6 Reconnect your outlets.
Launch the app & this will normally have cleared up the key-value compliance issues.

In my case it was the module that was specified to the wrong target. Simply deleting the module name and checking Inherit Module from target did the trick.

In my case, this was caused by referencing the wrong Nib:
BMTester *viewController = [[BMTester alloc] initWithNibName:#"WrongNibName" bundle:nil];

I was getting this error with storyboards. The above solution didn't seem to be the problem so I ended up deleting the view controller and adding it back in again (and of course reconnecting the segue and reassigning the class) which fixed it. I don't know what it really was, but I had renamed the associated view controller class shortly before this started, so maybe that had hosed something.

Related

Error: Thread 1: Exception: "this class is not key value coding-compliant for the key Label." [duplicate]

I'm trying to link a UILabel with an IBOutlet created in my class.
My application is crashing with the following error.
What does this mean?
How can I fix it?
*** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<UIViewController 0x6e36ae0> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key XXX.'
You may have a bad connection in your xib.
I've had this error many times. While TechZen's answer is absolutely right in this case, 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.
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":
Your view controller may have the wrong class in your xib.
I downloaded your project.
The error you are getting is
'NSUnknownKeyException', reason: '[<UIViewController 0x3927310> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key string.'
It is caused by the Second view controller in MainWindow.xib having a class of UIViewController instead of SecondView. Changing to the correct class resolves the problem.
By the way, it is bad practice to have names like "string" in Objective-C. It invites a runtime naming collision. Avoid them even in once off practice apps. Naming collisions can be very hard to track down and you don't want to waste the time.
Another possible reason for this error: when copying & pasting elements from one controller into another, Xcode somehow keeps that link to the original controller, even after editing & relinking this element into the new controller.
Another possible reason for this error:
Bad Outlet.
You have either removed or renamed an outlet name in your .h file.
Remove it in .xib or .storyboard file's Connection Inspector.
One more possible reason
(In my case) Extension of UIView with bindable properties and setting values for those bindable properties (i.e. shadow, corner radius etc.) then remove those properties from UIView extension (for some reason) but the following <userDefinedRuntimeAttributes> remained in xml (of foo.storyboard):
<userDefinedRuntimeAttributes>
<userDefinedRuntimeAttribute type="color" keyPath="shadowColor">
<color key="value" white="0.0" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
</userDefinedRuntimeAttribute>
<userDefinedRuntimeAttribute type="number" keyPath="shadowOpacity">
<real key="value" value="50"/>
</userDefinedRuntimeAttribute>
<userDefinedRuntimeAttribute type="point" keyPath="shadowOffset">
<point key="value" x="5" y="5"/>
</userDefinedRuntimeAttribute>
<userDefinedRuntimeAttribute type="number" keyPath="shadowRadius">
<real key="value" value="16"/>
</userDefinedRuntimeAttribute>
<userDefinedRuntimeAttribute type="number" keyPath="borderWidthValue">
<real key="value" value="0.0"/>
</userDefinedRuntimeAttribute>
</userDefinedRuntimeAttributes>
Solution: Right click on foo.storyboard > Open as Source Code > search by keyPath (i.e. shadowRadius) > Delete the </userDefinedRuntimeAttributes> that causing the problem
Sometimes this has to do with your "Inherit From Target" That value has to be set. With single target apps you can just select Inherit From Target. If you have more then one target select the desired target.
I had this error when I was trying to implement a custom ViewCell for a table. When I highlighted View controller for the XIB and connected to the elements in the CellView caused the error " this class is not key value coding-compliant for the key" once I deleted these it got rid of the error.
Delete the connections in the below image.
Just make sure that you only have the connections with the Table View Cell. To check click on table view cell and in INSPECTOR look for your connections.
I had to delete the app from the simulator/iPhone to get rid of this error.
If it is an iPhone only app, not a universal one, make sure the following field is empty:
Targets > Summary > iPhone/iPod Deployment Info > Main Interface
If you specify an xib there it crashes.
This error indicates that an already connected Interface Builder object is removed/renamed in its owner's source (File's Owner).
Control-click on the Files's Owner in the Interface Builder if you see a exclamation mark you need to fix that.
In the picture below you can see that "aRemovedView" has an exclamation mark on its right, that's because I removed the IBOutlet view object while it was already connected in the IB.
This gives the following error:
Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[ setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key aRemovedView.'
I had the same problem and while TechZen's answer may indeed be amazing I found it hard to apply to my situation.
Eventually I resolved the issue by linking the label via the Controller listed under Objects (highlighted in the image below) rather then via the File Owner.
Hope this helps.
in my case it was an error in the storyboard source code, follow these steps:
first open your story board as source code
search for <connections>
remove unwanted connections
For example:
<connections>
<outlet property="mapPostsView" destination="4EV-NK-Bhn" id="ubM-Z6-mwl"/>
<outlet property="mapView" destination="kx6-TV-oQg" id="4wY-jv-Ih6"/>
<outlet property="sidebarButton" destination="6UH-BZ-60q" id="8Yz-5G-HpY"/>
</connections>
As you see, these are connections between your code variables' names and the storyboard layout xml tags ;)
My fix was similar to Gerard Grundy's. In creating a custom UITableViewCell using an XIB, I had mistakenly applied the Custom Class name to the File's Owner instead of to the UITableViewCell. Applying the class to the UITableViewCell on the canvas and connecting my IBOutlet properties to it solved the issue.
You only need to specify IBOutlet once, the IBOutlet label your ivar is unnecessary.
Are you instantiating your NIB using your UIViewController? At some point you should be calling [SecondView initWithNibName:#"yourNibName" bundle:nil];
This was happening to me only when debugging on a device (iPhone). The iOS Simulator was working OK. Doing a "Product->Clean" from Xcode seemed to solve the problem, but I have no idea why.
I had exact same error message and thanks (!!) to Kira from http://www.idev101.com I was able to solve the challenge. I only found her site after googling and stacking over all these threads. I'm now posting here for the next one that comes to StackOverFlow and has the same challenge I had since that person will most likely come to this thread over Google.
I realized, that I wrongly made this:
UIViewController *deviceViewController = [[UIViewController alloc] initWithNibName:#"DeviceViewController" bundle:nil];
Instead of THIS:
DeviceViewController *deviceViewController = [[DeviceViewController alloc] initWithNibName:#"DeviceViewController" bundle:nil];
Where
DeviceViewController
Was the name of my Class also known as
DeviceViewController.h
DeviceViewController.m
You'll have to
"import DeviceViewController.h"
in your implementation (.m File) where you want to call e.g. another UIViewController.
I am absolutely not sorry if I am only stating the obvious for beginners like me and may get down votes as this is not exactly related to the question but I was searching 4 (?!?) hours straight now for the answer to these error message. If I can spare this to 1 or 2 people that'd be great :)
PS: For those interested in how the code continues for loading the other UIViewController:
[self presentViewController:deviceViewController animated:YES completion:nil];
It can come from the fact that you have control dragged and created an outlet or action, and forgot to delete it. Even if you deleted the code, or even if you have made enough cmd+Z, you'll need to go in the connection inspector of your storyboard and see if the action or outlet you created is still here or not.
Looking over the other answers it seems like there are a lot of things that can cause this error. Here is one more.
If you
have a custom view
added an #IBInspectable property
and then later deleted it
Then you may also get an error similar to
Failed to set (xxx) user defined inspected property on [Your Custom
View] ...: this class is not key value coding-compliant for the key
[xxx].
The solution is to delete the the old property.
Open the Identity inspector for your class, select the property name under User Defined Runtime Attributes, and press the minus button (-).
This happens to me when my view controller originally had an .xib file, but now is created programmatically.
Even though I have deleted the .xib file from this project. The users iPhone/iPad may contain an .xib files for this viewcontroller.
Attempting to load an .xib file usually causes this crash:
Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<UIViewController 0x18afe0> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key welcomeLabel.'
Solution when creating it programmatically may be this:
-(void)loadView {
// Ensure that we don't load an .xib file for this viewcontroller
self.view = [UIView new];
}
"Module" property of View Controller in the Identity Inspector might be different than what you expected. Also make sure that new classes are added to your target list.
I had a similar problem for a project that has two targets (with their own MainWindow XIB). The fundamental issue that caused this error for me was that the UIViewController class wasn't included in the second project's resource list. I.e. interface builder allowed me to specify it in MainWindow.xib, but at runtime the system couldn't locate the class.
I.e. cmd-click on the UIViewController class in question and double-check that it's included in the 'Targets' tab.
Just to add to this, because I was getting this error as well. Going through all these answers most seem to apply to working with the UI and storyboard stuff. I know the original poster did seem to be working with the UI but when searching for possible reasons for this error mostly all questions lead back to this question with those others being closed as duplicates or simply having issues with connecting things in a storyboard so I will add my solution.
I was working on coding a web service in Swift 2. I had built all the needed proxy objects and stubs. As I looped through the returned XML I was dynamically instantiating my objects, which all came from NSObject and using setValue:forKey on them. Every time setValue:forKey tried to set a property it blew up with this error.
I had a switch statement for each type I was dealing with (e.g. Bool?, CShort?, String?) and for each XML node I went through and checked what the type was on the object and then converted the value to that type and attempted to set it with setValue:forKey.
Eventually I started commenting out all these setValue:forKey lines and found that my default switch statement case did work for String?.
I finally figured out that you can't use optional swift types with setValue:forKey unless they have a direct mapping to an Objective-C type like String? or NSNumber?. I ended up changing all CShort? types to NSNumber? since that has a direct mapping. For Bool? in my case it was fine for me to just use Bool and initialize it to false. Others may not have that luxury.
Anyway what a headache that was so hopefully this helps someone else who has a similar problem and keeps getting redirected to this question and saying to themselves, "I am not doing anything in UI!!".
So lastly to reiterate one more time Key-Value Coding does not work with optionals. Below I ended up finding somewhere but I forget where so to whoever posted this I apologize and would give credit if I remembered where I found this but it saved my life:
You cannot use KVC on an Optional Int property, because KVC is Cocoa /
Objective-C, and Objective-C cannot see an Optional Int - it is not
bridged to Objective-C. Objective-C can only see types that are
bridged to Objective-C:
class types that are derived from NSObject
class types that are exposed with #objc
Swift structs that are bridged
"this class is not key value coding-compliant for the key"
I know its a bit late but my answer is different so I thinks it needs to be posted, I was pushing the second controller in wrong way, Here is sample
Wrong Way to Push Controller
UIViewController* controller = [[UIViewController
alloc]initWithNibName:#"TempViewController" bundle:nil];
[self.navigationController pushViewController:controller animated:true];
Correct way
TempViewController* controller = [[TempViewController
alloc]initWithNibName:#"TempViewController" bundle:nil];
[self.navigationController pushViewController:controller animated:true];
I did not found any answer like above so may be it can help some one having same issue
That might be the case of referencing a component from Xib Interface that you have renamed or delete. Re-referencing works for me.
I just had this issue in my duplicated project and solved by checking 2 places:
1- Make sure you have the .m file in the list -> Project - Build Phases - Compile Sources
2- After that, go to interface builder (probably this is an error occures with only IB) and unlink all properties, labels, images, etc... Then re-link all. I have realized that I've removed an attribute but it was still linked in IB.
Hope it works for some.
Another "not compliant" issue I found was when I managed to have two copies of a class for some reason.
I was adding keys to the wrong copy. Interface Builder still saw the keys and let me hook up to them, but at runtime it was using the other copy of the class that didn't have the new keys.
To find which was the "right" copy I used XCode's cmd-click on the class name elsewhere to jump to the correct copy, then I killed off the bad unused copies (after bringing over my edits from the un-used copy first).
Moral of the story: duplicate class files are bad.
This error is something else!
Here is how i Fixed it. I'm using xcode Version 6.1.1 and using swift. I got this error every time my app tried to perform a segue to jump to the next screen. Here what I did.
Checked that the button was connected to the right action.(This wasn't the problem, but still good to check)
Check that the button does not have any additional actions or outlets that you may have created by mistake. (This wasn't the problem, but still good to check)
Check the logs and make sure that all the buttons in the NEXT SCREEN have the correct actions, and if there are any segues, make sure that they have a unique identifier. (This was the problem)
One of the segues did not have a unique identifier
One of the buttons had an action and two outlets that I created by mistake.
Delete any additional outlets and make sure that you the segues to the next screen have unique identifiers.
Cheers,
In my case. I didn't have missing outlets in xib-files after merging.
Shift + Command + K
solved my problem. I cleaned my project and rebuilt.
I had the same symptom. The root cause was that the "Target Membership" for my source file was not set to the correct target. I assume that means my class wouldn't get built and included in my app.
To correct it:
Highlight your .m file.
In the right pane, select the File Inspector.
Under the "Target Membership" section, make sure the appropriate build target is checked.
Hope this helps somebody out there.
If you have a custom UIViewController subclass with IBOutlets that are causing problems the only set of steps I found to actually get rid of the error were
.1 Change the class to UIViewController
.2 Disconnect all the outlets (they will all have the yellow warning triangle now) - it may be enough just to disconnect the problematic outlet(s).
.3 Do all the standard steps - ↑⌘K, delete Derived Data (, prayer mats, worry beads)
.4 Launch the app - go to the problematic scene.
.5 Kill the app, go back to Interface Builder change the class back to your custom class name.
.6 Reconnect your outlets.
Launch the app & this will normally have cleared up the key-value compliance issues.
In my case it was the module that was specified to the wrong target. Simply deleting the module name and checking Inherit Module from target did the trick.
In my case, this was caused by referencing the wrong Nib:
BMTester *viewController = [[BMTester alloc] initWithNibName:#"WrongNibName" bundle:nil];
I was getting this error with storyboards. The above solution didn't seem to be the problem so I ended up deleting the view controller and adding it back in again (and of course reconnecting the segue and reassigning the class) which fixed it. I don't know what it really was, but I had renamed the associated view controller class shortly before this started, so maybe that had hosed something.

This class is not key value coding-compliant swift

Yes, there are several posts about this problem, but none of these seem to answer my problem?
I created a custom view in a nib file and connected it to code, exactly like here:
Link
Only differences:
My class is named EditorSectionView not CustomView
My outlet's name is customView, not contentView
Apart from the code, i did the following, as described in the gist:
In Interface-Builder, click on "File's Owner" and make the File owner's custom class "EditorSectionView", NOT the View itself
Drag and Drop the top level view (the "Custom view" named item from Interface Builder) to the EditorSectionView via Assistance Editor to create an outlet named customView.
Whenever i start the app and click on the button that should use this custom view, it crashes with the error:
"This class is not key value coding-compliant for the key customView".
However, when i have a look at the connections inspector, in my nib file, there is no "!" like some other posts pointed out and all seems to be fine.
I am using the nib file like that to instantiate it:
form +++ Section(field.name) {
let header = HeaderFooterView<EditorSectionView>(.nibFile(name: "EditorSectionView", bundle: nil))
}
This should create a new form section in Eureka, as described here: https://github.com/xmartlabs/Eureka/blob/master/README.md (Search for "You can use a Custom View from a .xib file:" in the readme).
I have tried to solve this for an hour now, but i don't know what else to do. All connections are set (the outlet, the class for the UI), the code itself copied from a gist, etc.
What am i doing wrong here?
Thanks.
EDIT:
If i set the custom class in the identity inspector as well to EditorSectionView, not only the File's Owner custom class to EditorSectionView, it doesn'T crash any more with "not coding compliant for key XY" but it crashes with EXC_BAD_ACCESS on the line i am calling loadNibNamed().
I found here the answer, that i should not set a custom class for the top level view, which will result again in "not coding compliant". So either way it still doesn't work...
Its difficult to tell without seeing what your connections are in the Xcode inspector, but sometimes if you connect an outlet and then rename it in your code, that outlet is still connected with the old name and you get a key-value compliance issue
Places to look are in the "User defined attributes table of your identity/inspector..
And also check your connections inspector

Cordova 3.8.0 Build Causes Errors in Iphone Apps locking up at Splash Screen [duplicate]

I'm trying to link a UILabel with an IBOutlet created in my class.
My application is crashing with the following error.
What does this mean?
How can I fix it?
*** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<UIViewController 0x6e36ae0> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key XXX.'
You may have a bad connection in your xib.
I've had this error many times. While TechZen's answer is absolutely right in this case, 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.
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":
Your view controller may have the wrong class in your xib.
I downloaded your project.
The error you are getting is
'NSUnknownKeyException', reason: '[<UIViewController 0x3927310> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key string.'
It is caused by the Second view controller in MainWindow.xib having a class of UIViewController instead of SecondView. Changing to the correct class resolves the problem.
By the way, it is bad practice to have names like "string" in Objective-C. It invites a runtime naming collision. Avoid them even in once off practice apps. Naming collisions can be very hard to track down and you don't want to waste the time.
Another possible reason for this error: when copying & pasting elements from one controller into another, Xcode somehow keeps that link to the original controller, even after editing & relinking this element into the new controller.
Another possible reason for this error:
Bad Outlet.
You have either removed or renamed an outlet name in your .h file.
Remove it in .xib or .storyboard file's Connection Inspector.
One more possible reason
(In my case) Extension of UIView with bindable properties and setting values for those bindable properties (i.e. shadow, corner radius etc.) then remove those properties from UIView extension (for some reason) but the following <userDefinedRuntimeAttributes> remained in xml (of foo.storyboard):
<userDefinedRuntimeAttributes>
<userDefinedRuntimeAttribute type="color" keyPath="shadowColor">
<color key="value" white="0.0" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
</userDefinedRuntimeAttribute>
<userDefinedRuntimeAttribute type="number" keyPath="shadowOpacity">
<real key="value" value="50"/>
</userDefinedRuntimeAttribute>
<userDefinedRuntimeAttribute type="point" keyPath="shadowOffset">
<point key="value" x="5" y="5"/>
</userDefinedRuntimeAttribute>
<userDefinedRuntimeAttribute type="number" keyPath="shadowRadius">
<real key="value" value="16"/>
</userDefinedRuntimeAttribute>
<userDefinedRuntimeAttribute type="number" keyPath="borderWidthValue">
<real key="value" value="0.0"/>
</userDefinedRuntimeAttribute>
</userDefinedRuntimeAttributes>
Solution: Right click on foo.storyboard > Open as Source Code > search by keyPath (i.e. shadowRadius) > Delete the </userDefinedRuntimeAttributes> that causing the problem
Sometimes this has to do with your "Inherit From Target" That value has to be set. With single target apps you can just select Inherit From Target. If you have more then one target select the desired target.
I had this error when I was trying to implement a custom ViewCell for a table. When I highlighted View controller for the XIB and connected to the elements in the CellView caused the error " this class is not key value coding-compliant for the key" once I deleted these it got rid of the error.
Delete the connections in the below image.
Just make sure that you only have the connections with the Table View Cell. To check click on table view cell and in INSPECTOR look for your connections.
I had to delete the app from the simulator/iPhone to get rid of this error.
If it is an iPhone only app, not a universal one, make sure the following field is empty:
Targets > Summary > iPhone/iPod Deployment Info > Main Interface
If you specify an xib there it crashes.
This error indicates that an already connected Interface Builder object is removed/renamed in its owner's source (File's Owner).
Control-click on the Files's Owner in the Interface Builder if you see a exclamation mark you need to fix that.
In the picture below you can see that "aRemovedView" has an exclamation mark on its right, that's because I removed the IBOutlet view object while it was already connected in the IB.
This gives the following error:
Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[ setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key aRemovedView.'
I had the same problem and while TechZen's answer may indeed be amazing I found it hard to apply to my situation.
Eventually I resolved the issue by linking the label via the Controller listed under Objects (highlighted in the image below) rather then via the File Owner.
Hope this helps.
in my case it was an error in the storyboard source code, follow these steps:
first open your story board as source code
search for <connections>
remove unwanted connections
For example:
<connections>
<outlet property="mapPostsView" destination="4EV-NK-Bhn" id="ubM-Z6-mwl"/>
<outlet property="mapView" destination="kx6-TV-oQg" id="4wY-jv-Ih6"/>
<outlet property="sidebarButton" destination="6UH-BZ-60q" id="8Yz-5G-HpY"/>
</connections>
As you see, these are connections between your code variables' names and the storyboard layout xml tags ;)
My fix was similar to Gerard Grundy's. In creating a custom UITableViewCell using an XIB, I had mistakenly applied the Custom Class name to the File's Owner instead of to the UITableViewCell. Applying the class to the UITableViewCell on the canvas and connecting my IBOutlet properties to it solved the issue.
You only need to specify IBOutlet once, the IBOutlet label your ivar is unnecessary.
Are you instantiating your NIB using your UIViewController? At some point you should be calling [SecondView initWithNibName:#"yourNibName" bundle:nil];
This was happening to me only when debugging on a device (iPhone). The iOS Simulator was working OK. Doing a "Product->Clean" from Xcode seemed to solve the problem, but I have no idea why.
I had exact same error message and thanks (!!) to Kira from http://www.idev101.com I was able to solve the challenge. I only found her site after googling and stacking over all these threads. I'm now posting here for the next one that comes to StackOverFlow and has the same challenge I had since that person will most likely come to this thread over Google.
I realized, that I wrongly made this:
UIViewController *deviceViewController = [[UIViewController alloc] initWithNibName:#"DeviceViewController" bundle:nil];
Instead of THIS:
DeviceViewController *deviceViewController = [[DeviceViewController alloc] initWithNibName:#"DeviceViewController" bundle:nil];
Where
DeviceViewController
Was the name of my Class also known as
DeviceViewController.h
DeviceViewController.m
You'll have to
"import DeviceViewController.h"
in your implementation (.m File) where you want to call e.g. another UIViewController.
I am absolutely not sorry if I am only stating the obvious for beginners like me and may get down votes as this is not exactly related to the question but I was searching 4 (?!?) hours straight now for the answer to these error message. If I can spare this to 1 or 2 people that'd be great :)
PS: For those interested in how the code continues for loading the other UIViewController:
[self presentViewController:deviceViewController animated:YES completion:nil];
It can come from the fact that you have control dragged and created an outlet or action, and forgot to delete it. Even if you deleted the code, or even if you have made enough cmd+Z, you'll need to go in the connection inspector of your storyboard and see if the action or outlet you created is still here or not.
Looking over the other answers it seems like there are a lot of things that can cause this error. Here is one more.
If you
have a custom view
added an #IBInspectable property
and then later deleted it
Then you may also get an error similar to
Failed to set (xxx) user defined inspected property on [Your Custom
View] ...: this class is not key value coding-compliant for the key
[xxx].
The solution is to delete the the old property.
Open the Identity inspector for your class, select the property name under User Defined Runtime Attributes, and press the minus button (-).
This happens to me when my view controller originally had an .xib file, but now is created programmatically.
Even though I have deleted the .xib file from this project. The users iPhone/iPad may contain an .xib files for this viewcontroller.
Attempting to load an .xib file usually causes this crash:
Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<UIViewController 0x18afe0> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key welcomeLabel.'
Solution when creating it programmatically may be this:
-(void)loadView {
// Ensure that we don't load an .xib file for this viewcontroller
self.view = [UIView new];
}
"Module" property of View Controller in the Identity Inspector might be different than what you expected. Also make sure that new classes are added to your target list.
I had a similar problem for a project that has two targets (with their own MainWindow XIB). The fundamental issue that caused this error for me was that the UIViewController class wasn't included in the second project's resource list. I.e. interface builder allowed me to specify it in MainWindow.xib, but at runtime the system couldn't locate the class.
I.e. cmd-click on the UIViewController class in question and double-check that it's included in the 'Targets' tab.
Just to add to this, because I was getting this error as well. Going through all these answers most seem to apply to working with the UI and storyboard stuff. I know the original poster did seem to be working with the UI but when searching for possible reasons for this error mostly all questions lead back to this question with those others being closed as duplicates or simply having issues with connecting things in a storyboard so I will add my solution.
I was working on coding a web service in Swift 2. I had built all the needed proxy objects and stubs. As I looped through the returned XML I was dynamically instantiating my objects, which all came from NSObject and using setValue:forKey on them. Every time setValue:forKey tried to set a property it blew up with this error.
I had a switch statement for each type I was dealing with (e.g. Bool?, CShort?, String?) and for each XML node I went through and checked what the type was on the object and then converted the value to that type and attempted to set it with setValue:forKey.
Eventually I started commenting out all these setValue:forKey lines and found that my default switch statement case did work for String?.
I finally figured out that you can't use optional swift types with setValue:forKey unless they have a direct mapping to an Objective-C type like String? or NSNumber?. I ended up changing all CShort? types to NSNumber? since that has a direct mapping. For Bool? in my case it was fine for me to just use Bool and initialize it to false. Others may not have that luxury.
Anyway what a headache that was so hopefully this helps someone else who has a similar problem and keeps getting redirected to this question and saying to themselves, "I am not doing anything in UI!!".
So lastly to reiterate one more time Key-Value Coding does not work with optionals. Below I ended up finding somewhere but I forget where so to whoever posted this I apologize and would give credit if I remembered where I found this but it saved my life:
You cannot use KVC on an Optional Int property, because KVC is Cocoa /
Objective-C, and Objective-C cannot see an Optional Int - it is not
bridged to Objective-C. Objective-C can only see types that are
bridged to Objective-C:
class types that are derived from NSObject
class types that are exposed with #objc
Swift structs that are bridged
"this class is not key value coding-compliant for the key"
I know its a bit late but my answer is different so I thinks it needs to be posted, I was pushing the second controller in wrong way, Here is sample
Wrong Way to Push Controller
UIViewController* controller = [[UIViewController
alloc]initWithNibName:#"TempViewController" bundle:nil];
[self.navigationController pushViewController:controller animated:true];
Correct way
TempViewController* controller = [[TempViewController
alloc]initWithNibName:#"TempViewController" bundle:nil];
[self.navigationController pushViewController:controller animated:true];
I did not found any answer like above so may be it can help some one having same issue
That might be the case of referencing a component from Xib Interface that you have renamed or delete. Re-referencing works for me.
I just had this issue in my duplicated project and solved by checking 2 places:
1- Make sure you have the .m file in the list -> Project - Build Phases - Compile Sources
2- After that, go to interface builder (probably this is an error occures with only IB) and unlink all properties, labels, images, etc... Then re-link all. I have realized that I've removed an attribute but it was still linked in IB.
Hope it works for some.
Another "not compliant" issue I found was when I managed to have two copies of a class for some reason.
I was adding keys to the wrong copy. Interface Builder still saw the keys and let me hook up to them, but at runtime it was using the other copy of the class that didn't have the new keys.
To find which was the "right" copy I used XCode's cmd-click on the class name elsewhere to jump to the correct copy, then I killed off the bad unused copies (after bringing over my edits from the un-used copy first).
Moral of the story: duplicate class files are bad.
This error is something else!
Here is how i Fixed it. I'm using xcode Version 6.1.1 and using swift. I got this error every time my app tried to perform a segue to jump to the next screen. Here what I did.
Checked that the button was connected to the right action.(This wasn't the problem, but still good to check)
Check that the button does not have any additional actions or outlets that you may have created by mistake. (This wasn't the problem, but still good to check)
Check the logs and make sure that all the buttons in the NEXT SCREEN have the correct actions, and if there are any segues, make sure that they have a unique identifier. (This was the problem)
One of the segues did not have a unique identifier
One of the buttons had an action and two outlets that I created by mistake.
Delete any additional outlets and make sure that you the segues to the next screen have unique identifiers.
Cheers,
In my case. I didn't have missing outlets in xib-files after merging.
Shift + Command + K
solved my problem. I cleaned my project and rebuilt.
I had the same symptom. The root cause was that the "Target Membership" for my source file was not set to the correct target. I assume that means my class wouldn't get built and included in my app.
To correct it:
Highlight your .m file.
In the right pane, select the File Inspector.
Under the "Target Membership" section, make sure the appropriate build target is checked.
Hope this helps somebody out there.
If you have a custom UIViewController subclass with IBOutlets that are causing problems the only set of steps I found to actually get rid of the error were
.1 Change the class to UIViewController
.2 Disconnect all the outlets (they will all have the yellow warning triangle now) - it may be enough just to disconnect the problematic outlet(s).
.3 Do all the standard steps - ↑⌘K, delete Derived Data (, prayer mats, worry beads)
.4 Launch the app - go to the problematic scene.
.5 Kill the app, go back to Interface Builder change the class back to your custom class name.
.6 Reconnect your outlets.
Launch the app & this will normally have cleared up the key-value compliance issues.
In my case it was the module that was specified to the wrong target. Simply deleting the module name and checking Inherit Module from target did the trick.
In my case, this was caused by referencing the wrong Nib:
BMTester *viewController = [[BMTester alloc] initWithNibName:#"WrongNibName" bundle:nil];
I was getting this error with storyboards. The above solution didn't seem to be the problem so I ended up deleting the view controller and adding it back in again (and of course reconnecting the segue and reassigning the class) which fixed it. I don't know what it really was, but I had renamed the associated view controller class shortly before this started, so maybe that had hosed something.

Weird XIB file issue

Experiencing a weird problem in a modified program written by me. In my first iteration, the view controller had an IBAction by the title userSpecifyingInput and had all my buttons wired up to this IBAction.
To make the design more sophisticated, I introduced userSpecifyingDigit and userSpecifyingLetter and accordingly had some buttons wiring up to the first IBAction (userSpecifyingDigit) and the next button wiring up to the second IBAction (userSpecifyingLetter).
Upon running my program, it gave me this error:
terminating app: NSInvalidArgumentException
Unrecognized selector sent to instance
And these selectors were alternating between userSpecifyingInput and userSpecifyingDigit which did not make sense as userSpecifyingInput was completely removed from my ViewControllers interface and implementations.
Now I am not sure why userSpecifyingInput still existed, but after dabbling with sent events, I noticed that the buttons were wired upto the new selectors as well as the old selector.
I had to manually remove the old selector from the touchupinside events for all the buttons.
Naturally this does not seem to be a very convenient way to go about proceedings and if the view controller selectors are modified then the touch events ought to be automatically removed.
Am I missing something here? This is a pretty open ended question with different answers
Eliminating an IBAction from your implementation will not remove any previous links to it in IB. I haven't heard of any XCode/IB preferences to shortcut this issue.
Sounds like the xib still thinks one of it's objects is hooked up to the UIViewController, but the function on the UIViewController is no longer there. To check and fix this...
Click on the xib file in the project navigator
Select the File's Owner
Click on the Connections Inspector
Verify that none of these connections are invalid
I would also look in the UIViewController to make sure no automagically created references exist here as well.

iPhone app crashing with NSUnknownKeyException setValue:forUndefinedKey: [duplicate]

This question already has answers here:
Xcode - How to fix 'NSUnknownKeyException', reason: … this class is not key value coding-compliant for the key X" error?
(79 answers)
Closed 7 years ago.
I'm writing my first iPhone app, so I haven't gotten around to figuring out much in the way of debugging.
Essentially my app displays an image and when touched plays a short sound.
When compiling and building the project in XCode, everything builds successfully, but when the app is run in the iPhone simulator, it crashes.
I get the following error:
Application Specific Information:
iPhone Simulator 1.0 (70), iPhone OS 2.0 (5A331)
*** Terminating app due to uncaught exception 'NSUnknownKeyException',
reason: '[<UIView 0x34efd0> setValue:forUndefinedKey:]: this class is not key value
coding-compliant for the key kramerImage.'
kramerImage here is the image I'm using for the background.
I'm not sure what NSUnknownKeyException means or why the class is not key value coding-compliant for the key.
(This isn't really iPhone specific - the same thing will happen in regular Cocoa).
NSUnknownKeyException is a common error when using Key-Value Coding to access a key that the object doesn't have.
The properties of most Cocoa objects can be accessing directly:
[#"hello world" length] // Objective-C 1.0
#"hello world".length // Objective-C 2.0
Or via Key-Value Coding:
[#"hello world" valueForKey:#"length"]
I would get an NSUnknownKeyException if I used the following line:
[#"hello world" valueForKey:#"purpleMonkeyDishwasher"]
because NSString does not have a property (key) called 'purpleMonkeyDishwasher'.
Something in your code is trying to set a value for the key 'kramerImage' on an UIView, which (apparently) doesn't support that key. If you're using Interface Builder, it might be something in your nib.
Find where 'kramerImage' is being used, and try to track it down from there.
Also when you rename a view, don't forget to delete the reference on File's Owner. It may also raise this error.
Here's one where you'll get this error - and how to fix it. I was getting it when loading a nib that just had a custom TableViewCell. I used IB to build a xib that just had the File's Owner, First Responder, and the TableViewCell. The TableViewCell just had 4 UILabels which matched up to a class with 4 IBOutlet UILabels called rootCell. I changed the class of the TableViewCell to be rootCell. It worked fine until a made a couple of changes and suddenly I was getting the setValue:forUndefinedKey: when I was just instantiating the class after loading it from a nib:
NSArray * nib = [[NSBundle mainBundle] loadNibNamed:#"rootCell-iPad" owner:self options:nil];
cell = [nib objectAtIndex:0];
It failed at the first line, when the nib was trying to load. After a while, I noticed that it was trying to match the IBOutlet Labels to the root controller, NOT the rootCell class! That was my tipoff. What I did wrong was to inadvertently change the File's Owner to rootCell class. When I changed it back to NSObject, then it didn't try to match up to the delegate (rootController) when loading. So, if you're doing the above, make File's Owner an NSObject, but make the UITableCell your desired class.
I had this situation and it turns out even after finding all instances of the variable and deleting them my app still crashed. Heres what happened... I created another instance of a variable from a textfield from my XIB into my viewController.h but I realized I didnt need it anymore and deleted it. It turns out my program saw that and kept trying to use it in the program so in the future if this happens to anywhere else just go into you XIB right-click on the button or textfield etc and delete any extra unused variables.
I had this same problem today. I didn't have the right class specified for the View Controller in my Navigation Controller. This will happen often if you fail to specify the correct class for your views in Interface Builder.
You'll also get invalid selector issues as well. Always check your Interface Builder classes and connections!
This is how i solved mine, in Interface builder right-click the View Controller, there should be an exclamation mark on the missing outlet or action method. Find and remove all the references and that solved it.
This happened because i deleted the action method in the .m file.
It seems you are doing
#interface MyFirstIphoneAppViewController : UIViewController<> {
UIImageView *InitialkramerImage;
}
#property(nonatomic,retain) IBOutlet UIImageView *InitialkramerImage;
Then after synthesizing that imageview, When you open "MyFirstIphoneAppViewController.xib" in Interface Builder, you are taking an Image View from Tool(menu)/Library den linking that outlet to the 'InitialkramerImage' from the Files Owner of "MyFirstIphoneAppViewController.xib". Then you saved the project. But after that you might change the name of the outlet variable "InitialkramerImage" to "kramerImage". So, after doing this
#interface MyFirstIphoneAppViewController : UIViewController<> {
UIImageView *kramerImage;
}
#property(nonatomic,retain) IBOutlet UIImageView *kramerImage;
and saving the project when you run it, There is no existance of the outlet of "InitialkramerImage" in the "MyFirstIphoneAppViewController.xib". So, when you run the project there will be no outlet referencing from Imageview to the 'kramerImage' and
"For displaying the view,
UIViewController will try to find the
outlet to "InitialkramerImage" which
is not existing."
So, It will throw the "NSUnknownKeyException".
You can check the missing outlet by
opening the nib(.xib) file then right
clicking on the 'Files Owner' of that.
If you have done this code somewhere else and had a zip/compressed file, try to extract it again. It may work I dont know why but I feel like it is an extraction issue.
or you can try to change the IBOutlet to kramerImage and bind it again in NIB.