I am running xcode 5.1.1 and have been trying to learn objective C / iOS development. Right now whenever I try to run my code on the emulator (I do not have an actual device atm) it comes up with a black screen. Code can be found here. Compiling and running gives me the following error:
2014-08-23 10:42:57.429 Calculator[1862:60b] *** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<XYZViewController 0xe436640> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key didgetPressed.'
*** First throw call stack:
(
0 CoreFoundation 0x017ed1e4 __exceptionPreprocess + 180
1 libobjc.A.dylib 0x0156c8e5 objc_exception_throw + 44
2 CoreFoundation 0x0187cfe1 -[NSException raise] + 17
3 Foundation 0x0122cd9e -[NSObject(NSKeyValueCoding) setValue:forUndefinedKey:] + 282
4 Foundation 0x011991d7 _NSSetUsingKeyValueSetter + 88
5 Foundation 0x01198731 -[NSObject(NSKeyValueCoding) setValue:forKey:] + 267
6 Foundation 0x011fab0a -[NSObject(NSKeyValueCoding) setValue:forKeyPath:] + 412
7 UIKit 0x004e31f4 -[UIRuntimeOutletConnection connect] + 106
8 libobjc.A.dylib 0x0157e7de -[NSObject performSelector:] + 62
9 CoreFoundation 0x017e876a -[NSArray makeObjectsPerformSelector:] + 314
10 UIKit 0x004e1d4d -[UINib instantiateWithOwner:options:] + 1417
11 UIKit 0x0034a6f5 -[UIViewController _loadViewFromNibNamed:bundle:] + 280
12 UIKit 0x0034ae9d -[UIViewController loadView] + 302
13 UIKit 0x0034b0d3 -[UIViewController loadViewIfRequired] + 78
14 UIKit 0x0034b5d9 -[UIViewController view] + 35
15 UIKit 0x0026b267 -[UIWindow addRootViewControllerViewIfPossible] + 66
16 UIKit 0x0026b5ef -[UIWindow _setHidden:forced:] + 312
17 UIKit 0x0026b86b -[UIWindow _orderFrontWithoutMakingKey] + 49
18 UIKit 0x002763c8 -[UIWindow makeKeyAndVisible] + 65
19 UIKit 0x00226bc0 -[UIApplication _callInitializationDelegatesForURL:payload:suspended:] + 2097
20 UIKit 0x0022b667 -[UIApplication _runWithURL:payload:launchOrientation:statusBarStyle:statusBarHidden:] + 824
21 UIKit 0x0023ff92 -[UIApplication handleEvent:withNewEvent:] + 3517
22 UIKit 0x00240555 -[UIApplication sendEvent:] + 85
23 UIKit 0x0022d250 _UIApplicationHandleEvent + 683
24 GraphicsServices 0x037e2f02 _PurpleEventCallback + 776
25 GraphicsServices 0x037e2a0d PurpleEventCallback + 46
26 CoreFoundation 0x01768ca5 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 53
27 CoreFoundation 0x017689db __CFRunLoopDoSource1 + 523
28 CoreFoundation 0x0179368c __CFRunLoopRun + 2156
29 CoreFoundation 0x017929d3 CFRunLoopRunSpecific + 467
30 CoreFoundation 0x017927eb CFRunLoopRunInMode + 123
31 UIKit 0x0022ad9c -[UIApplication _run] + 840
32 UIKit 0x0022cf9b UIApplicationMain + 1225
33 Calculator 0x00002c8d main + 141
34 libdyld.dylib 0x01e34701 start + 1
35 ??? 0x00000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb)
I have attempted the following things, and so far nothing has worked
1) checked the deployment info, it has the main interface set to main
2) double checked all break points to turn them off and disabled all of them through Debug->Disable Breakpoints
3) Reset Content and Settings on the iOS Simulator.
4) Checked the issue with the LLDB Debugger, however from what I have read the issue is no longer present with the 5.1.1 xcode.
5) checked the local host is still set to 127.0.0.1
Thanks!
- Terryn
I checked out your project. The IBActions for the digits (didgetPressed:) are connected correctly, but the IBOutlets are not connected correctly (the property didgetPressed does not exist).
It will work when you delete the referencing outlets in the storyboard (see picture).
This error message tells us what's wrong:
2014-08-23 10:42:57.429 Calculator[1862:60b] * Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[ setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key didgetPressed.'
From this we can deduce that, in your storyboard (or xib), you have an object of class XYZViewController. That object once had an outlet named didgetPressed, and you connected that outlet to something else in the storyboard.
Later, you changed something about your project that removed the didgetPressed outlet from that object, but you didn't disconnect the outlet in your storyboard. For example, maybe you changed the outlet name in your Objective-C code to didGetPressed, or maybe you deleted the outlet and changed it to an action, or maybe you changed the object's class (and the prior class had the didgetPressed outlet).
You need to find the XYZViewController object in your storyboard and disconnect the didgetPressed outlet.
The error is self explanatory you can remove that by opening storyboard select XYZViewController goto connection inspector under Utilities panel and remove binding of didgetPressed.
I have check you code just select button with 7 as title and remove it's referencing outlet and run again it will work.
Related
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.
Everytime I create an outlet for a UITextField it breaks my app. No build errors just termination at boot.
"2015-11-27 17:34:19.005 ticTacToe[3540:71629] *** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<ViewController 0x7fbb82682450> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key wins.'
*** First throw call stack:
(
0 CoreFoundation 0x000000010d8b0c65 __exceptionPreprocess + 165
1 libobjc.A.dylib 0x000000010c003bb7 objc_exception_throw + 45
2 CoreFoundation 0x000000010d8b08a9 -[NSException raise] + 9
3 Foundation 0x000000010bb99b53 -[NSObject(NSKeyValueCoding) setValue:forKey:] + 259
4 CoreFoundation 0x000000010d7f8d50 -[NSArray makeObjectsPerformSelector:] + 224
5 UIKit 0x000000010c51d4eb -[UINib instantiateWithOwner:options:] + 1506
6 UIKit 0x000000010c3756d8 -[UIViewController _loadViewFromNibNamed:bundle:] + 242
7 UIKit 0x000000010c375cc8 -[UIViewController loadView] + 109
8 UIKit 0x000000010c375f39 -[UIViewController loadViewIfRequired] + 75
9 UIKit 0x000000010c3763ce -[UIViewController view] + 27
10 UIKit 0x000000010c291289 -[UIWindow addRootViewControllerViewIfPossible] + 58
11 UIKit 0x000000010c29164f -[UIWindow _setHidden:forced:] + 247
12 UIKit 0x000000010c29dde1 -[UIWindow makeKeyAndVisible] + 42
13 UIKit 0x000000010c241417 -[UIApplication _callInitializationDelegatesForMainScene:transitionContext:] + 2732
14 UIKit 0x000000010c24419e -[UIApplication _runWithMainScene:transitionContext:completion:] + 1349
15 UIKit 0x000000010c243095 -[UIApplication workspaceDidEndTransaction:] + 179
16 FrontBoardServices 0x0000000111bc95e5 __31-[FBSSerialQueue performAsync:]_block_invoke_2 + 21
17 CoreFoundation 0x000000010d7e441c __CFRUNLOOP_IS_CALLING_OUT_TO_A_BLOCK__ + 12
18 CoreFoundation 0x000000010d7da165 __CFRunLoopDoBlocks + 341
19 CoreFoundation 0x000000010d7d9f25 __CFRunLoopRun + 2389
20 CoreFoundation 0x000000010d7d9366 CFRunLoopRunSpecific + 470
21 UIKit 0x000000010c242b02 -[UIApplication _run] + 413
22 UIKit 0x000000010c2458c0 UIApplicationMain + 1282
23 ticTacToe 0x000000010b6f386f main + 111
24 libdyld.dylib 0x000000010eaac145 start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException"
If possible please explain fix visually as I am programming retarded :-)
Further to Hayden's answer - you can easily check to see if any IBOutlets which you think should be connected to your View Controller are actually not connected by looking at the margin in Xcode (as below). Each IBOutlet will display a filled in circle showing you that it's connected to an element on the storyboard.
If the circle is empty it's not connected which can cause a crash...
Hi I am making an app and want to use a button to switch from one view controller to another view controller. I used a modal segue and made a UIbutton action calling performSegueWithIdentifier. However, I got
Terminating with uncaught exception of type NSException
error in AppleDelegate file. I have no idea what's going on here. PLease help me! THanks a lot.
Here is what the program explains:
2015-11-20 01:22:21.575 Photo book[17126:547637] Unknown class ViewController1 in Interface Builder file.
2015-11-20 01:22:21.581 Photo book[17126:547637] *** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<UIViewController 0x7f9698e1d2b0> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key Open.'
*** First throw call stack:
(
0 CoreFoundation 0x0000000103d7fc65 __exceptionPreprocess + 165
1 libobjc.A.dylib 0x0000000103a18bb7 objc_exception_throw + 45
2 CoreFoundation 0x0000000103d7f8a9 -[NSException raise] + 9
3 Foundation 0x00000001035aeb53 -[NSObject(NSKeyValueCoding) setValue:forKey:] + 259
4 CoreFoundation 0x0000000103cc7d50 -[NSArray makeObjectsPerformSelector:] + 224
5 UIKit 0x000000010469252b -[UINib instantiateWithOwner:options:] + 1506
6 UIKit 0x00000001048f4aba -[UIStoryboard instantiateViewControllerWithIdentifier:] + 181
7 UIKit 0x00000001048f80bf -[UIStoryboardSegueTemplate _perform:] + 71
8 UIKit 0x0000000111251638 -[UIViewControllerAccessibility performSegueWithIdentifier:sender:] + 39
9 Photo book 0x0000000103479c66 _TFC10Photo_book14ViewController5LoginfS0_FCSo8UIButtonT_ + 278
10 Photo book 0x0000000103479cea _TToFC10Photo_book14ViewController5LoginfS0_FCSo8UIButtonT_ + 58
11 UIKit 0x00000001043bbda2 -[UIApplication sendAction:to:from:forEvent:] + 75
12 UIKit 0x00000001044cd54a -[UIControl _sendActionsForEvents:withEvent:] + 467
13 UIKit 0x00000001044cc919 -[UIControl touchesEnded:withEvent:] + 522
14 UIKit 0x0000000104408998 -[UIWindow _sendTouchesForEvent:] + 735
15 UIKit 0x00000001044092c2 -[UIWindow sendEvent:] + 682
16 UIKit 0x00000001043cf581 -[UIApplication sendEvent:] + 246
17 UIKit 0x00000001043dcd1c _UIApplicationHandleEventFromQueueEvent + 18265
18 UIKit 0x00000001043b75dc _UIApplicationHandleEventQueue + 2066
19 CoreFoundation 0x0000000103cb3431 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
20 CoreFoundation 0x0000000103ca92fd __CFRunLoopDoSources0 + 269
21 CoreFoundation 0x0000000103ca8934 __CFRunLoopRun + 868
22 CoreFoundation 0x0000000103ca8366 CFRunLoopRunSpecific + 470
23 GraphicsServices 0x00000001085cda3e GSEventRunModal + 161
24 UIKit 0x00000001043ba900 UIApplicationMain + 1282
25 Photo book 0x000000010348b1c7 main + 135
26 libdyld.dylib 0x0000000106965145 start + 1
27 ??? 0x0000000000000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb)
this error occurs when you accidently delete iboutlet from your .h file but they are still connected in your xib or storyboard.. make sure that all your iboutlets are connected properly in your second view.
First set you class name as following
Then set segue identifier
And check weather if you have deleted any IBOutlet accidentally or you have change name of controls programatically then respective outlet not found.
I am new to coding and Xcode. The problem I am facing with is stated in the title. I hope anyone can help me out of it.
The error message will be pasted at below
2015-07-13 01:11:36.443 Main_Iphone 6[2570:94488] *** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<Main_Iphone_6.ViewController 0x7fccc8432560> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key Button.'
First throw call stack:
(
0 CoreFoundation 0x0000000100c02c65 __exceptionPreprocess + 165
1 libobjc.A.dylib 0x000000010276dbb7 objc_exception_throw + 45
2 CoreFoundation 0x0000000100c028a9 -[NSException raise] + 9
3 Foundation 0x0000000101020b53 -[NSObject(NSKeyValueCoding) setValue:forKey:] + 259
4 CoreFoundation 0x0000000100b4ad50 -[NSArray makeObjectsPerformSelector:] + 224
5 UIKit 0x00000001017794eb -[UINib instantiateWithOwner:options:] + 1506
6 UIKit 0x00000001015d16d8 -[UIViewController _loadViewFromNibNamed:bundle:] + 242
7 UIKit 0x00000001015d1cc8 -[UIViewController loadView] + 109
8 UIKit 0x00000001015d1f39 -[UIViewController loadViewIfRequired] + 75
9 UIKit 0x00000001015d23ce -[UIViewController view] + 27
10 UIKit 0x00000001014ed289 -[UIWindow addRootViewControllerViewIfPossible] + 58
11 UIKit 0x00000001014ed64f -[UIWindow _setHidden:forced:] + 247
12 UIKit 0x00000001014f9de1 -[UIWindow makeKeyAndVisible] + 42
13 UIKit 0x000000010149d417 -[UIApplication _callInitializationDelegatesForMainScene:transitionContext:] + 2732
14 UIKit 0x00000001014a019e -[UIApplication _runWithMainScene:transitionContext:completion:] + 1349
15 UIKit 0x000000010149f095 -[UIApplication workspaceDidEndTransaction:] + 179
16 FrontBoardServices 0x000000010426a5e5 __31-[FBSSerialQueue performAsync:]_block_invoke_2 + 21
17 CoreFoundation 0x0000000100b3641c __CFRUNLOOP_IS_CALLING_OUT_TO_A_BLOCK__ + 12
18 CoreFoundation 0x0000000100b2c165 __CFRunLoopDoBlocks + 341
19 CoreFoundation 0x0000000100b2bf25 __CFRunLoopRun + 2389
20 CoreFoundation 0x0000000100b2b366 CFRunLoopRunSpecific + 470
21 UIKit 0x000000010149eb02 -[UIApplication _run] + 413
22 UIKit 0x00000001014a18c0 UIApplicationMain + 1282
23 Main_Iphone 6 0x0000000100a101d7 main + 135
24 libdyld.dylib 0x0000000102ea3145 start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
You've got an outlet called Button defined in a storyboard or xib file, but the thing you're connecting it to doesn't have a property of the same name. Either you've deleted an IBOutlet from code or you've not set the correct view controller class in the identity inspector in interface builder.
The most important information is this class is not key value coding-compliant for the key Button.
From the backtrace you can see, that after an UINib is instantiated
[UINib instantiateWithOwner:options:]
there is a method sent to all objects of an array
[NSArray makeObjectsPerformSelector:]
to set the value of a property Button
[NSObject(NSKeyValueCoding) setValue:forKey:]
This property must be synthesized or have explicit setter and getter to be key value coding-compliant.
Set an Exception Breakpoint to find the exact location of the crash and look into your model classes for a missing property Button
I'm a beginner working through Ray Wenderlich's Swift tutorial, Part 2.
The final code for the lesson (and with which I'm receiving the error) is here: http://cdn5.raywenderlich.com/wp-content/uploads/2014/06/TipCalculator-Demo4.zip
When I build the app through Xcode 6.3.2 and run it on the iOS simulator (iPhone 6), I get the error message below (sorry for the poor formatting).
I did a search on both Google and StackOverflow, seems like people often run into similar errors but are able to fix it by going to the view controller, checking the Connections Inspector, and fixing any of the connections that are flagged (e.g., an object being connected to no longer exists).
Note: I don't have any flags in my Connections Inspector -- everything seems fine there, including the connection between resultsTextView and Text View object in the Storyboard (please see attached photo)
Please let me know how to solve this - thanks.
---------See Connection Inspector on far right - looks fine!-----------
http://i.imgur.com/X6eA05F.png
---------Error message---------
2015-06-05 17:07:39.866 TipCalculator[4848:128801] * Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[ setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key resultsTextView.'
* First throw call stack:
(
0 CoreFoundation 0x0000000100216c65 __exceptionPreprocess + 165
1 libobjc.A.dylib 0x0000000101d81bb7 objc_exception_throw + 45
2 CoreFoundation 0x00000001002168a9 -[NSException raise] + 9
3 Foundation 0x0000000100634b53 -[NSObject(NSKeyValueCoding) setValue:forKey:] + 259
4 CoreFoundation 0x000000010015ed50 -[NSArray makeObjectsPerformSelector:] + 224
5 UIKit 0x0000000100d8d52b -[UINib instantiateWithOwner:options:] + 1506
6 UIKit 0x0000000100be5718 -[UIViewController _loadViewFromNibNamed:bundle:] + 242
7 UIKit 0x0000000100be5d08 -[UIViewController loadView] + 109
8 UIKit 0x0000000100be5f79 -[UIViewController loadViewIfRequired] + 75
9 UIKit 0x0000000100c1601b -[UINavigationController _layoutViewController:] + 44
10 UIKit 0x0000000100c16565 -[UINavigationController _updateScrollViewFromViewController:toViewController:] + 216
11 UIKit 0x0000000100c16664 -[UINavigationController _startTransition:fromViewController:toViewController:] + 92
12 UIKit 0x0000000100c17448 -[UINavigationController _startDeferredTransitionIfNeeded:] + 523
13 UIKit 0x0000000100c17f0e -[UINavigationController __viewWillLayoutSubviews] + 43
14 UIKit 0x0000000100d62715 -[UILayoutContainerView layoutSubviews] + 202
15 UIKit 0x0000000100b35a2b -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 536
16 QuartzCore 0x0000000104916ec2 -[CALayer layoutSublayers] + 146
17 QuartzCore 0x000000010490b6d6 _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 380
18 QuartzCore 0x000000010490b546 _ZN2CA5Layer28layout_and_display_if_neededEPNS_11TransactionE + 24
19 QuartzCore 0x0000000104877886 _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 242
20 QuartzCore 0x0000000104878a3a _ZN2CA11Transaction6commitEv + 462
21 UIKit 0x0000000100ab3a2d -[UIApplication _reportMainSceneUpdateFinished:] + 44
22 UIKit 0x0000000100ab46f1 -[UIApplication _runWithMainScene:transitionContext:completion:] + 2648
23 UIKit 0x0000000100ab30d5 -[UIApplication workspaceDidEndTransaction:] + 179
24 FrontBoardServices 0x00000001038915e5 __31-[FBSSerialQueue performAsync:]_block_invoke_2 + 21
25 CoreFoundation 0x000000010014a41c __CFRUNLOOP_IS_CALLING_OUT_TO_A_BLOCK__ + 12
26 CoreFoundation 0x0000000100140165 __CFRunLoopDoBlocks + 341
27 CoreFoundation 0x000000010013f947 __CFRunLoopRun + 887
28 CoreFoundation 0x000000010013f366 CFRunLoopRunSpecific + 470
29 UIKit 0x0000000100ab2b42 -[UIApplication _run] + 413
30 UIKit 0x0000000100ab5900 UIApplicationMain + 1282
31 TipCalculator 0x000000010002c177 main + 135
32 libdyld.dylib 0x00000001024d9145 start + 1
33 ??? 0x0000000000000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb)
Make sure you follow those steps correctly:
Open Main.storyboard and select your View Controller in the Document
Outline. Open the Connections Inspector (6th tab), and you will see
all of the properties you created listed in the Outlets section.
021_ConnectionsInspector You’ll notice a small circle to the right of
resultsTextView. Control-drag from that button down to the text view
below the Calculate button, and release to connect your Swift property
to this view.
I believe you are missing the #IBOutlet that is create in this step
Does anyone have any ideas, this is killing me. Create an app from a Single View Application template, delete the storyboard and ViewController.swift file and then add a new view controller called MainViewController with a Xib.
Change the project settings for Main Interface from Main to MainViewController and run.
In previous versions of Xcode this would have worked fine. Now no matter what I try I cannot get this to work. Tried initialising the View Controller in the App Delegate but no joy, it just crashes with this exception:
2014-11-22 11:14:48.084 TestApp[9781:422842] *** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<UIApplication 0x7fd510611320> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key view.'
*** First throw call stack:
(
0 CoreFoundation 0x00000001025c9f35 __exceptionPreprocess + 165
1 libobjc.A.dylib 0x000000010410dbb7 objc_exception_throw + 45
2 CoreFoundation 0x00000001025c9b79 -[NSException raise] + 9
3 Foundation 0x00000001029e17b3 -[NSObject(NSKeyValueCoding) setValue:forKey:] + 259
4 CoreFoundation 0x0000000102513e80 -[NSArray makeObjectsPerformSelector:] + 224
5 UIKit 0x000000010311ac7d -[UINib instantiateWithOwner:options:] + 1506
6 UIKit 0x000000010311c722 -[NSBundle(UINSBundleAdditions) loadNibNamed:owner:options:] + 160
7 UIKit 0x0000000102e54b11 -[UIApplication _loadMainNibFileNamed:bundle:] + 46
8 UIKit 0x0000000102e53c19 -[UIApplication _runWithMainScene:transitionContext:completion:] + 1075
9 UIKit 0x0000000102e52bf2 -[UIApplication workspaceDidEndTransaction:] + 179
10 FrontBoardServices 0x0000000105cad2a3 __31-[FBSSerialQueue performAsync:]_block_invoke + 16
11 CoreFoundation 0x00000001024ff53c __CFRUNLOOP_IS_CALLING_OUT_TO_A_BLOCK__ + 12
12 CoreFoundation 0x00000001024f5285 __CFRunLoopDoBlocks + 341
13 CoreFoundation 0x00000001024f5045 __CFRunLoopRun + 2389
14 CoreFoundation 0x00000001024f4486 CFRunLoopRunSpecific + 470
15 UIKit 0x0000000102e52669 -[UIApplication _run] + 413
16 UIKit 0x0000000102e55420 UIApplicationMain + 1282
17 TestApp 0x00000001023e9cae top_level_code + 78
18 TestApp 0x00000001023e9cea main + 42
19 libdyld.dylib 0x00000001048e7145 start + 1
20 ??? 0x0000000000000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
You need to provide a xib or storyboard file for the Main Interface. Not a ViewController.
Also make sure you don't have any dangling outlets. Make sure that the objects in the xib don't have an outlet set which does not exist in your ViewController.h or ViewController.m