Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

iOS

Terminating app due to uncaught exception 'NSUnknownKeyException

I'm making a simple app to add to-do list items tutorial...

I'm getting "Thread 1: signal SIGABRT" after pressing a bar button item on UINavigation to add an item... loading the app on the iOS Simulator. The bar button item only has one triggered segue to show a new add item view controller

But I don't understand why, I'm sure I linked all the UI elements correctly, checked the names

2015-07-25 22:14:00.781 KiwiAddItemV[21899:1048729] *** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<KiwiAddItemV.AddViewController 0x7f8a7a579cd0> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key pickupTextField.' *** First throw call stack: ( 0 CoreFoundation 0x000000010d1c4c65 exceptionPreprocess + 165 1 libobjc.A.dylib 0x000000010ed2fbb7 objc_exception_throw + 45 2 CoreFoundation 0x000000010d1c48a9 -[NSException raise] + 9 3 Foundation 0x000000010d5e2b53 -[NSObject(NSKeyValueCoding) setValue:forKey:] + 259 4 CoreFoundation 0x000000010d10cd50 -[NSArray makeObjectsPerformSelector:] + 224 5 UIKit 0x000000010dd3b4eb -[UINib instantiateWithOwner:options:] + 1506 6 UIKit 0x000000010db936d8 -[UIViewController _loadViewFromNibNamed:bundle:] + 242 7 UIKit 0x000000010db93cc8 -[UIViewController loadView] + 109 8 UIKit 0x000000010db93f39 -[UIViewController loadViewIfRequired] + 75 9 UIKit 0x000000010db943ce -[UIViewController view] + 27 10 UIKit 0x000000010dbb9257 -[UINavigationController _startCustomTransition:] + 633 11 UIKit 0x000000010dbc537f -[UINavigationController _startDeferredTransitionIfNeeded:] + 386 12 UIKit 0x000000010dbc5ece -[UINavigationController __viewWillLayoutSubviews] + 43 13 UIKit 0x000000010dd106d5 -[UILayoutContainerView layoutSubviews] + 202 14 UIKit 0x000000010dae39eb -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 536 15 QuartzCore 0x00000001118b1ed2 -[CALayer layoutSublayers] + 146 16 QuartzCore 0x00000001118a66e6 _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 380 17 QuartzCore 0x00000001118a6556 _ZN2CA5Layer28layout_and_display_if_neededEPNS_11TransactionE + 24 18 QuartzCore 0x000000011181286e _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 242 19 QuartzCore 0x0000000111813a22 _ZN2CA11Transaction6commitEv + 462 20 UIKit 0x000000010da605e6 _UIApplicationHandleEventQueue + 2140 21 CoreFoundation 0x000000010d0f8431 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION + 17 22 CoreFoundation 0x000000010d0ee2fd __CFRunLoopDoSources0 + 269 23 CoreFoundation 0x000000010d0ed934 __CFRunLoopRun + 868 24 CoreFoundation 0x000000010d0ed366 CFRunLoopRunSpecific + 470 25 GraphicsServices 0x0000000111198a3e GSEventRunModal + 161 26 UIKit 0x000000010da638c0 UIApplicationMain + 1282 27 KiwiAddItemV 0x000000010cf9b6b7 main + 135 28 libdyld.dylib 0x000000010f465145 start + 1 ) libc++abi.dylib: terminating with uncaught exception of type NSException (lldb)

Here's the app delegate.swift file, the first thread starts at "class AppDelegate: UIResponder, UIApplicationDelegate {": import UIKit

@UIApplicationMain

class AppDelegate: UIResponder, UIApplicationDelegate {

var window: UIWindow?

func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
    // Override point for customization after application launch.
    return true
}

func applicationWillResignActive(application: UIApplication) {
    // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
    // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
}


func applicationDidEnterBackground(application: UIApplication) {
    // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
    // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
}

func applicationWillEnterForeground(application: UIApplication) {
    // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
}

func applicationDidBecomeActive(application: UIApplication) {
    // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
}

func applicationWillTerminate(application: UIApplication) {
    // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
}

}

1 Answer

This error means that somewhere in your project you have setup a controller or object that expects an item named: "pickupTextField".

This is probably something that is in the storyboard. You can right-click in the storyboard scenes, controllers, views, etc., and check to see if there is any connection to an outlet of that name. Also make sure you are not calling this from your source files, though the most likely scenario is that this problem is within your storyboard and thus, it's why you cannot see it in code.

Hope this helps :)