ios libc++abi.dylib:以未捕获的 NSException 类型异常(lldb)终止
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/26442414/
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
libc++abi.dylib: terminating with uncaught exception of type NSException (lldb)
提问by Nick
I'm programming an app in swift and when I run the test app on the iPhone simulator everything works, but then I try to swipe right, which is a gesture that I added for it to go to the next Page(View Controller Two) it crashes and shows this error report in the console log.
我正在快速编写一个应用程序,当我在 iPhone 模拟器上运行测试应用程序时一切正常,但随后我尝试向右滑动,这是我为它添加到下一个页面(视图控制器二)的手势它崩溃并在控制台日志中显示此错误报告。
2014-10-18 12:07:34.400 soundtest[17081:818922] *** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<soundtest.ViewControllerTwo 0x7f92f1f20090> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key sfdfa.'
*** First throw call stack:
(
0 CoreFoundation 0x00000001067813f5 __exceptionPreprocess + 165
1 libobjc.A.dylib 0x00000001082afbb7 objc_exception_throw + 45
2 CoreFoundation 0x0000000106781039 -[NSException raise] + 9
3 Foundation 0x0000000106b984d3 -[NSObject(NSKeyValueCoding) setValue:forKey:] + 259
4 CoreFoundation 0x00000001066cb400 -[NSArray makeObjectsPerformSelector:] + 224
5 UIKit 0x00000001072ce97d -[UINib instantiateWithOwner:options:] + 1506
6 UIKit 0x000000010712f698 -[UIViewController _loadViewFromNibNamed:bundle:] + 242
7 UIKit 0x000000010712fc88 -[UIViewController loadView] + 109
8 UIKit 0x000000010712fef9 -[UIViewController loadViewIfRequired] + 75
9 UIKit 0x000000010713038e -[UIViewController view] + 27
10 UIKit 0x00000001076cd83f -[_UIFullscreenPresentationController _setPresentedViewController:] + 65
11 UIKit 0x000000010710bc49 -[UIPresentationController initWithPresentedViewController:presentingViewController:] + 105
12 UIKit 0x000000010713c121 -[UIViewController _presentViewController:withAnimationController:completion:] + 1746
13 UIKit 0x000000010713e461 __62-[UIViewController presentViewController:animated:completion:]_block_invoke + 132
14 UIKit 0x000000010713e385 -[UIViewController presentViewController:animated:completion:] + 229
15 UIKit 0x00000001073bb9d6 _UIGestureRecognizerSendActions + 262
16 UIKit 0x00000001073ba679 -[UIGestureRecognizer _updateGestureWithEvent:buttonEvent:] + 532
17 UIKit 0x00000001073bf296 ___UIGestureRecognizerUpdate_block_invoke662 + 51
18 UIKit 0x00000001073bf192 _UIGestureRecognizerRemoveObjectsFromArrayAndApplyBlocks + 254
19 UIKit 0x00000001073b520d _UIGestureRecognizerUpdate + 2796
20 UIKit 0x00000001070520a6 -[UIWindow _sendGesturesForEvent:] + 1041
21 UIKit 0x0000000107052cd3 -[UIWindow sendEvent:] + 667
22 UIKit 0x000000010701fae1 -[UIApplication sendEvent:] + 246
23 UIKit 0x000000010702cbad _UIApplicationHandleEventFromQueueEvent + 17370
24 UIKit 0x0000000107008233 _UIApplicationHandleEventQueue + 1961
25 CoreFoundation 0x00000001066b6ad1 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
26 CoreFoundation 0x00000001066ac99d __CFRunLoopDoSources0 + 269
27 CoreFoundation 0x00000001066abfd4 __CFRunLoopRun + 868
28 CoreFoundation 0x00000001066aba06 CFRunLoopRunSpecific + 470
29 GraphicsServices 0x000000010a1699f0 GSEventRunModal + 161
30 UIKit 0x000000010700b550 UIApplicationMain + 1282
31 soundtest 0x000000010624503e top_level_code + 78
32 soundtest 0x000000010624507a main + 42
33 libdyld.dylib 0x000000010ae4a145 start + 1
34 ??? 0x0000000000000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb)
回答by Trapp
CMYR - "his could also happen if you've wired up a button to an IBAction that doesn't exist anymore (or has been renamed)"
CMYR - “如果您将按钮连接到不再存在(或已重命名)的 IBAction,他也可能发生”
If you're running into this problem make sure that you go to Main.storyboard, RIGHT click on the yellow box icon (view controller) at the top of the phone outline and DELETE the outlet(s) with yellow flags.
如果您遇到此问题,请确保转到 Main.storyboard,右键单击电话轮廓顶部的黄色框图标(视图控制器)并删除带有黄色标志的插座。
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 sim!
在这种情况下会发生什么是你可能命名了一个动作,然后重命名了它。您需要删除旧名称,如果这是唯一的问题,将在 sim 中立即启动!
回答by Siddhesh Mahadeshwar
Did you set the OS_ACTIVITY_MODE variable by any chance? To check if you have this variable set (and turn it off), in Xcode 9, do the following:
您是否偶然设置了 OS_ACTIVITY_MODE 变量?要检查您是否设置了此变量(并将其关闭),请在 Xcode 9 中执行以下操作:
Select from Xcode menu Product -> Scheme -> Edit Scheme..
Select the Run scheme and look under Arguments.
If you see the OS_ACTIVITY_MODE variable checked, deselect it
Select from Xcode menu Product -> Scheme -> Edit Scheme..
Select the Run scheme and look under Arguments.
If you see the OS_ACTIVITY_MODE variable checked, deselect it
回答by Ahmed Lotfy
In Xcode 9 and Swift 4:
在 Xcode 9 和 Swift 4 中:
Print exception stack to know the reason of the exception:
打印异常堆栈以了解异常原因:
- Go to show break point navigator.
Add (+) Add Exception Breakpoint.
Select the new breakpoint, Control-Click, Edit Breakpoint.
- Add Action and Enter: po $arg1
- 转到显示断点导航器。
添加 (+) 添加异常断点。
选择新断点,按住 Control 键单击,编辑断点。
- 添加操作并输入:po $arg1
回答by Naveed Abbas
In my case, I was calling a delegate method but the method wasn't declared.
就我而言,我正在调用委托方法,但未声明该方法。
This error is generic and can appear by a number of reasons. Make sure you have not disabled your Logs to actually see what happened. Enable OS_ACTIVITY_MODEin the schemes if you have disabled it. You might have disabled it to prevent a lot of irrelevant logs but they are handy.
此错误是通用的,可能由多种原因出现。确保您没有禁用日志以实际查看发生了什么。如果您已禁用它,请在方案中启用 OS_ACTIVITY_MODE。您可能已禁用它以防止大量不相关的日志,但它们很方便。
You can also trace the cause in more details by adding an exception breakpoint po $arg1
. As already mentioned by Ahmed-Lotfi
您还可以通过添加异常断点来更详细地跟踪原因po $arg1
。正如 Ahmed-Lotfi 已经提到的
Here is a common checklist that you can go through.
这是您可以查看的通用清单。
2) Check if you have renamed an IBOutlet and calling it
3) Check if you have renamed a method name or the method doesn't exist
4) Check if you are trying to add or remove any view from hierarchy
5) Check for any missing framework or library
6) Check if you've forgot to register your custom cell identifier
7) Check for any missing flag in the Proejct Setting (-obj) or any other linker flag etc.
回答by Andrej
Other solutions didn't work form me, here's mine. It applies only to Xcode 8 when running in Swift 2.3legacy mode:
其他解决方案对我不起作用,这是我的。在 Swift 2.3传统模式下运行时,它仅适用于 Xcode 8:
Looks like Interface Builder is trying to rename the method that should be hooked up to the button.
看起来 Interface Builder 正在尝试重命名应该连接到按钮的方法。
Here's a radarwith more details.
The solution (workaround) is to manually replace the method parameter name to _
:
解决方案(变通方法)是手动将方法参数名称替换为_
:
@IBAction func editPictureTapped(sender: UIButton) { // not working
print("Tapped")
}
Change to this:
改成这样:
@IBAction func editPictureTapped(_: UIButton) { // working OK
print("Tapped")
}
回答by M_R_K
It could also be wrong Segue Identifier Name. Eg -
也可能是错误的 Segue 标识符名称。例如——
performSegueWithIdentifier("wrongSegueName", sender: self)
回答by Simon
My situation was a little different, I was trying to segue into a UINavigationController
, and what fixed it for me was getting the main queue portion.
我的情况有点不同,我试图进入一个UINavigationController
,而对我来说修复它的是获取主队列部分。
For Objective-C:
对于 Objective-C:
dispatch_async(dispatch_get_main_queue(), ^{
[self performSegueWithIdentifier:@"SegueName" sender:self];
});
For Swift 3:
对于 Swift 3:
DispatchQueue.main.async { [weak self] in
self?.performSegue(withIdentifier: "SegueName", sender: self)
}
回答by Chris Livdahl
For me, the problem was in my IBAction with a UIButton.
对我来说,问题出在我的带有 UIButton 的 IBAction 中。
When you Ctrl+Drag to create an IBAction from a UIButton, make sure to select "UIButton" from the Type dropdown. The default selection of AnyObject causes the app to crash when you tap on the UIButton.
当您按 Ctrl+拖动从 UIButton 创建 IBAction 时,请确保从类型下拉列表中选择“UIButton”。当您点击 UIButton 时,默认选择 AnyObject 会导致应用程序崩溃。
回答by Eran Talmor
This started to happen for me on Xcode 7, and I had no outlets with yellow flags that I could delete.
这开始发生在我的 Xcode 7 上,我没有可以删除的带有黄色标志的插座。
The only thing that worked for me was replacing this line in the AppDelegate:
唯一对我有用的是替换 AppDelegate 中的这一行:
[window addSubview:viewController.view];
to:
到:
[window setRootViewController:viewController];
回答by Cons Bulaquena
It could also be a broken Triggered Segues, check in your storyboard, as soon as you reconnectthe segues or outlet it all should work again.
它也可能是一个损坏的 Triggered Segues,检查你的故事板,一旦你重新连接segues 或 outlet,它应该会再次工作。
Make sure the Identifier
of the Segue is correct and similar to your code.
确保Identifier
Segue 的正确且与您的代码相似。