ios Xcode 8:以 NSException 类型的未捕获异常终止

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/40005899/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-31 10:34:05  来源:igfitidea点击:

Xcode 8: Terminating with Uncaught exception of type NSException

iosswiftxcode8

提问by nano_dorado

I'm a newbie and i'm having this error, i looked up everywhere and i can't find the solution. Any help would be really appreciated!

我是新手,我遇到了这个错误,我到处查找,但找不到解决方案。任何帮助将非常感激!

  0   CoreFoundation                      0x00000001102bb34b __exceptionPreprocess + 171
  1   libobjc.A.dylib                     0x000000010d61c21e objc_exception_throw + 48
  2   CoreFoundation                      0x00000001102bb299 -[NSException raise] + 9
  3   Foundation                          0x000000010d12c2ff -[NSObject(NSKeyValueCoding) setValue:forKey:] + 291
  4   UIKit                               0x000000010dbafc01 -[UIView(CALayerDelegate) setValue:forKey:] + 173
  5   UIKit                               0x000000010def9be6 -[UIRuntimeOutletConnection connect] + 109
  6   CoreFoundation                      0x0000000110260590 -[NSArray makeObjectsPerformSelector:] + 256
  7   UIKit                               0x000000010def856a -[UINib instantiateWithOwner:options:] + 1867
  8   UIKit                               0x000000010dc451e8 -[UITableView _dequeueReusableViewOfType:withIdentifier:] + 399
  9   UIKit                               0x000000010dc456e0 -[UITableView dequeueReusableCellWithIdentifier:forIndexPath:] + 71
  10  Foodtracker                         0x000000010d0274e7 _TFC11Foodtracker23MealTableViewController9tableViewfTCSo11UITableView12cellForRowAtV10Foundation9IndexPath_CSo15UITableViewCell + 199
  11  Foodtracker                         0x000000010d027a97 _TToFC11Foodtracker23MealTableViewController9tableViewfTCSo11UITableView12cellForRowAtV10Foundation9IndexPath_CSo15UITableViewCell + 87
  12  UIKit                               0x000000010dc58ba9 -[UITableView _createPreparedCellForGlobalRow:withIndexPath:willDisplay:] + 757
  13  UIKit                               0x000000010dc58e07 -[UITableView _createPreparedCellForGlobalRow:willDisplay:] + 74
  14  UIKit                               0x000000010dc2c871 -[UITableView _updateVisibleCellsNow:isRecursive:] + 3295
  15  UIKit                               0x000000010dc62189 -[UITableView _performWithCachedTraitCollection:] + 110
  16  UIKit                               0x000000010dc489e3 -[UITableView layoutSubviews] + 222
  17  UIKit                               0x000000010dbb0344 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 1237
  18  QuartzCore                          0x000000011306acdc -[CALayer layoutSublayers] + 146
  19  QuartzCore                          0x000000011305e7a0 _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 366
  20  QuartzCore                          0x000000011305e61e _ZN2CA5Layer28layout_and_display_if_neededEPNS_11TransactionE + 24
  21  QuartzCore                          0x0000000112fec62c _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 280
  22  QuartzCore                          0x0000000113019713 _ZN2CA11Transaction6commitEv + 475
  23  QuartzCore                          0x000000011301a083 _ZN2CA11Transaction17observer_callbackEP19__CFRunLoopObservermPv + 113
  24  CoreFoundation                      0x000000011025fe17 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 23
  25  CoreFoundation                      0x000000011025fd87 __CFRunLoopDoObservers + 391
  26  CoreFoundation                      0x00000001102444b6 CFRunLoopRunSpecific + 454
  27  UIKit                               0x000000010dae5db6 -[UIApplication _run] + 434
  28  UIKit                               0x000000010daebf34 UIApplicationMain + 159
  29  Foodtracker                         0x000000010d028c4f main + 111
  30  libdyld.dylib                       0x00000001111e568d start + 1
  31  ???                                 0x0000000000000001 0x0 + 1

) libc++abi.dylib: terminating with uncaught exception of type NSException (lldb)

) libc++abi.dylib: 以 NSException (lldb) 类型的未捕获异常终止

回答by Andrew Veresov

Check your storyboard: All the IBAction, IBOutlet connected and with their current names? It's actually happens when problem with iboutlets

检查您的故事板:所有 IBAction、IBOutlet 都已连接并使用它们当前的名称?它实际上发生在 iboutlets 出现问题时

回答by budidino

If you just updated to Swift 4and have issues running your app on iOS 11 device or simulator, maybe you have the same issue I had with the UIVisualEffectView, and specifically with adding subviews to it.

如果您刚刚更新到Swift 4并且在 iOS 11 设备或模拟器上运行您的应用程序时遇到问题,那么您可能遇到了与我相同的问题UIVisualEffectView,特别是在向其添加子视图方面。

Apple's documentationsays:

苹果的文档说:

Add subviews to the contentView and not to UIVisualEffectView directly.

将子视图添加到 contentView 而不是直接添加到 UIVisualEffectView。

Basically, instead of adding subviews directly to the UIVisualEffectView, add them to its .contentView.

基本上,不是将子视图直接UIVisualEffectView添加到.contentView.

Example:

例子:

// create UIVisualEffectView
let blackBlur = UIVisualEffectView(effect: UIBlurEffect(style: .dark))

// adding a subview - this worked on iOS 10 - crashes the app on iOS 11
blackBlur.addSubview(someView)

// this works on both iOS 10 and iOS 11
blackBlur.contentView.addSubview(someView)

I hope this helps someone since it took me a while to figure this one out.

我希望这对某人有所帮助,因为我花了一段时间才弄明白。

回答by Atlas_Gondal

If anyone is running into this problem make sure that you

如果有人遇到此问题,请确保您

  1. Go to Main.storyboard
  2. RIGHT click on the yellow box icon (view controller) at the top of the phone outline
  3. DELETE the outlet(s) with yellow flags.
  1. 转到 Main.storyboard
  2. 右键单击手机轮廓顶部的黄色框图标(视图控制器)
  3. 删除带有黄色标志的插座。

What happens in instances like this is you probably named an action, then renamed it. You need to delete the old name and if that was the only issue will start right up in simulator!

在这种情况下会发生什么是你可能命名了一个动作,然后重命名了它。您需要删除旧名称,如果这是唯一的问题,将在模拟器中立即启动!

NOTE:most of the time this happens because of wrong connection so double check and make sure all outlet connections are correct.

注意:大多数情况下发生这种情况是因为连接错误,因此请仔细检查并确保所有插座连接正确。

回答by Ahmadiah

If you are using Firebase and have this problem when you upload be careful with the key value. The keys should not include '#' or '%' or etc. I just deleted and worked fine.

如果您使用 Firebase 并在上传时遇到此问题,请注意键值。键不应包含“#”或“%”等。我刚刚删除并且工作正常。

回答by AirXygène

The raising method is setValue:forKey:, which is called after a table view cell was dequeued. Apparently in the MealTableViewController.

提升方法是 setValue:forKey:,它在表视图单元出列后调用。显然在 MealTableViewController 中。

Check your table view cells XIB, there might be an IBOutlet remaining with a wrong name, or maybe a property set with the wrong name.

检查您的表格视图单元格 XIB,可能还有一个名称错误的 IBOutlet,或者可能是一个名称错误的属性集。