简单 Swift 步进器错误

Simple Swift Stepper error

我是 Swift 的新手,正在尝试步进器等功能。我遵循了有关如何制作的在线分步说明,但出现错误(附在下面)并且我不太了解问题出在哪里。

错误:

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

查看:

检查你的步进器在你的故事板中是否有多余的插座。右键单击 Storyboard 中的 stepper 对象并检查是否有您不想要的插座。

还有。删除 @Iboutlet var textV:UILabel! 或将其与情节提要中的标签重新连接,错误就会消失。