-2

Since this error varies I'm not sure what is wrong

console error message:
 *** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<Pitch_Perfect.PlaySoundsViewController 0x7f8b82e13830> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key test.'
*** First throw call stack:
(
    0   CoreFoundation                      0x0000000109ab83f5 __exceptionPreprocess + 165
    1   libobjc.A.dylib                     0x000000010b5e6bb7 objc_exception_throw + 45
    2   CoreFoundation                      0x0000000109ab8039 -[NSException raise] + 9
    3   Foundation                          0x0000000109ecf4d3 -[NSObject(NSKeyValueCoding) setValue:forKey:] + 259
    4   CoreFoundation                      0x0000000109a02400 -[NSArray makeObjectsPerformSelector:] + 224
    5   UIKit                               0x000000010a60597d -[UINib instantiateWithOwner:options:] + 1506
    6   UIKit                               0x000000010a466698 -[UIViewController _loadViewFromNibNamed:bundle:] + 242
    7   UIKit                               0x000000010a466c88 -[UIViewController loadView] + 109
    8   UIKit                               0x000000010a466ef9 -[UIViewController loadViewIfRequired] + 75
    9   UIKit                               0x000000010a46738e -[UIViewController view] + 27
    10  UIKit                               0x000000010a48aa77 -[UINavigationController _startCustomTransition:] + 633
    11  UIKit                               0x000000010a49696e -[UINavigationController _startDeferredTransitionIfNeeded:] + 386
    12  UIKit                               0x000000010a4974b7 -[UINavigationController __viewWillLayoutSubviews] + 43
    13  UIKit                               0x000000010a5db399 -[UILayoutContainerView layoutSubviews] + 202
    14  UIKit                               0x000000010a3bb199 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 521
    15  QuartzCore                          0x000000010d3c6f98 -[CALayer layoutSublayers] + 150
    16  QuartzCore                          0x000000010d3bbbbe _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 380
    17  QuartzCore                          0x000000010d3bba2e _ZN2CA5Layer28layout_and_display_if_neededEPNS_11TransactionE + 24
    18  QuartzCore                          0x000000010d329ade _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 242
    19  QuartzCore                          0x000000010d32abea _ZN2CA11Transaction6commitEv + 390
    20  UIKit                               0x000000010a33f27d _UIApplicationHandleEventQueue + 2035
    21  CoreFoundation                      0x00000001099edad1 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
    22  CoreFoundation                      0x00000001099e399d __CFRunLoopDoSources0 + 269
    23  CoreFoundation                      0x00000001099e2fd4 __CFRunLoopRun + 868
    24  CoreFoundation                      0x00000001099e2a06 CFRunLoopRunSpecific + 470
    25  GraphicsServices                    0x000000010da659f0 GSEventRunModal + 161
    26  UIKit                               0x000000010a342550 UIApplicationMain + 1282
    27  Pitch Perfect                       0x000000010957f7ce top_level_code + 78
    28  Pitch Perfect                       0x000000010957f80a main + 42
    29  libdyld.dylib                       0x000000010bdc0145 start + 1
    30  ???                                 0x0000000000000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb) 
Rob
  • 415,655
  • 72
  • 787
  • 1,044
Niels
  • 1

1 Answers1

1

Typically, this happens because you set up an outlet and then deleted the property. For example, let's say you had an outlet called test:

IBOutlet UILabel* test;

Or:

@property (nonatomic, weak) IBOutlet UILabel* test;

And let's say you had this all set up, including the label in your interface in the nib (storyboard). But now let's say you delete that line of code. So this leaves the label and its outlet still in your nib, trying to form the connection to an ivar / property called test in your code - and that code is no longer there. Thus, you crash when the nib loads and the connection can't be formed.

There are then variations on that sort of mistake. For example, you didn't delete the code, but you changed the name of the class. But it's all a variety of the same thing - you have a mismatch between the name of an outlet in your nib and the actual file's owner when the nib loads.

matt
  • 515,959
  • 87
  • 875
  • 1,141