ios - NSException 类型的未捕获异常(连接似乎很好) - Wenderlich 教程

标签 ios xcode swift debugging nsexception

我是一名初学者,正在学习 Ray Wenderlich 的 Swift 教程,第 2 部分。

本课的最终代码(我收到错误)在这里:http://cdn5.raywenderlich.com/wp-content/uploads/2014/06/TipCalculator-Demo4.zip

当我通过 Xcode 6.3.2 构建应用程序并在 iOS 模拟器 (iPhone 6) 上运行它时,我收到以下错误消息(对于格式不佳表示抱歉)。

我在 Google 和 StackOverflow 上进行了搜索,似乎人们经常遇到类似的错误,但可以通过转到 View Controller 、检查连接检查器并修复任何标记的连接来修复它(例如,所连接的对象不再存在)。

注意:我的连接检查器中没有任何标志 - 一切看起来都很好,包括 Storyboard 中 resultsTextView 和 Text View 对象之间的连接(请参阅附图)

请告诉我如何解决这个问题 - 谢谢。

---------请参阅最右侧的连接检查器 - 看起来不错!---------

http://i.imgur.com/X6eA05F.png

---------错误信息---------

2015-06-05 17:07:39.866 TipCalculator[4848:128801] * 由于未捕获的异常“NSUnknownKeyException”而终止应用程序,原因:“[ setValue:forUndefinedKey:]:此类不是键值编码- 符合关键结果TextView。' *第一次抛出调用堆栈:

(
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:以 NSException 类型的未捕获异常终止 (lldb)

最佳答案

确保正确执行这些步骤:

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.

我相信您缺少在此步骤中创建的@IBOutlet

关于ios - NSException 类型的未捕获异常(连接似乎很好) - Wenderlich 教程,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30677612/

相关文章:

iOS-所有应用程序图标和启动器大小

xcode - IBOutlet 为零,但它在 Storyboard Swift 中已连接

ios - Swift 2.0 Beta试图使UITextview能够被拖动

swift - 为什么我不能对字典使用 SetValue?

ios - 如何在 swift 3 中按 tableView 上的搜索键时关闭键盘?

ios - 在CallKit中调用reportOutgoingCall时打不开应用程序?

iphone - 如何从 Facebook 登录重定向到 iphone 应用程序

ios - 我在代码中发现了一个僵尸,现在该怎么办?

xcode - 升级 XCode 5.0 -> 5.1 "forward declaration of class cannot have a nested name specifier"后,C++ 代码编译失败

ios - 未找到 ios 开发证书且未找到未过期的配置文件