Search code examples
iosxcodeswiftuistepper

Simple Swift Stepper error


I'm new to Swift and am experimenting with things such as the stepper. I followed online step-by-step instructions on how to make one but I'm getting an error (Attached below) and I am not quite understanding where the issue is.

Error:

2016-06-04 04:31:15.832 numChsnger[12025:1111078] *** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<numChsnger.ViewController 0x7fc082695990> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key stepper.'
*** First throw call stack:
(
0   CoreFoundation                      0x0000000102328d85 __exceptionPreprocess + 165
1   libobjc.A.dylib                     0x00000001040ccdeb objc_exception_throw + 48
2   CoreFoundation                      0x00000001023289c9 -[NSException raise] + 9
3   Foundation                          0x00000001026fa19b -[NSObject(NSKeyValueCoding) setValue:forKey:] + 288
4   UIKit                               0x0000000102ce3d0c -[UIViewController setValue:forKey:] + 88
5   UIKit                               0x0000000102f1a7fb -[UIRuntimeOutletConnection connect] + 109
6   CoreFoundation                      0x0000000102262890 -[NSArray makeObjectsPerformSelector:] + 224
7   UIKit                               0x0000000102f191de -[UINib instantiateWithOwner:options:] + 1864
8   UIKit                               0x0000000102cea8d6 -[UIViewController _loadViewFromNibNamed:bundle:] + 381
9   UIKit                               0x0000000102ceb202 -[UIViewController loadView] + 178
10  UIKit                               0x0000000102ceb560 -[UIViewController loadViewIfRequired] + 138
11  UIKit                               0x0000000102cebcd3 -[UIViewController view] + 27
12  UIKit                               0x0000000102bc1fb4 -[UIWindow addRootViewControllerViewIfPossible] + 61
13  UIKit                               0x0000000102bc269d -[UIWindow _setHidden:forced:] + 282
14  UIKit                               0x0000000102bd4180 -[UIWindow makeKeyAndVisible] + 42
15  UIKit                               0x0000000102b48ed9 -[UIApplication _callInitializationDelegatesForMainScene:transitionContext:] + 4131
16  UIKit                               0x0000000102b4f568 -[UIApplication _runWithMainScene:transitionContext:completion:] + 1769
17  UIKit                               0x0000000102b4c714 -[UIApplication workspaceDidEndTransaction:] + 188
18  FrontBoardServices                  0x0000000105f5d8c8 __FBSSERIALQUEUE_IS_CALLING_OUT_TO_A_BLOCK__ + 24
19  FrontBoardServices                  0x0000000105f5d741 -[FBSSerialQueue _performNext] + 178
20  FrontBoardServices                  0x0000000105f5daca -[FBSSerialQueue _performNextFromRunLoopSource] + 45
21  CoreFoundation                      0x000000010224e301 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
22  CoreFoundation                      0x000000010224422c __CFRunLoopDoSources0 + 556
23  CoreFoundation                      0x00000001022436e3 __CFRunLoopRun + 867
24  CoreFoundation                      0x00000001022430f8 CFRunLoopRunSpecific + 488
25  UIKit                               0x0000000102b4bf21 -[UIApplication _run] + 402
26  UIKit                               0x0000000102b50f09 UIApplicationMain + 171
27  numChsnger                          0x0000000102144382 main + 114
28  libdyld.dylib                       0x0000000104b9092d start + 1
)
 libc++abi.dylib: terminating with uncaught exception of type NSException

View:

enter image description here


Solution

  • Check if your stepper has a redundant outlet in your storyboard. Right click on the stepper object in Storyboard and check if there is any outlet you don't want.

    enter image description here

    Also. Remove @Iboutlet var textV:UILabel! or reconnect it with the Label in your storyboard and the error will be gone.