昨天我的 iPhone 应用程序运行得很好。今天我遇到了这个崩溃:
*** 由于未捕获的异常“NSGenericException”而终止应用程序,原因:“此编码器要求从 initWithCoder 返回替换的对象:”
当使用 Storyboard转场从一个 View 转到另一个 View 时会发生这种情况(也以编程方式尝试过)。目标 View Controller 是一个 UITableViewController ,这没什么奇怪的。我已经回滚了我的代码以检查是否有任何更改导致此崩溃,但什么也没有。我所做的最新测试版本仍然可以使用相同的代码正常工作。
有人知道可能出了什么问题吗?我没有主意了。
这是堆栈跟踪:
0 CoreFoundation 0x0000000107f176fb __exceptionPreprocess + 331
1 libobjc.A.dylib 0x0000000106f0bac5 objc_exception_throw + 48
2 CoreFoundation 0x0000000107f17555 +[NSException raise:format:] + 197
3 UIFoundation 0x000000010d3fe89c UINibDecoderDecodeObjectForValue + 827
4 UIFoundation 0x000000010d3feaf9 UINibDecoderDecodeObjectForValue + 1432
5 UIFoundation 0x000000010d3fe554 -[UINibDecoder decodeObjectForKey:] + 251
6 UIKitCore 0x000000010f4b0330 -[UIViewController initWithCoder:] + 1021
7 UIKitCore 0x000000010f4a52ab -[UITableViewController initWithCoder:] + 59
8 Tankey 0x0000000100c8ede4 $s6Tankey25BaseUITableViewControllerC5coderACSgSo7NSCoderC_tcfc + 148
9 Tankey 0x0000000100c8ee8f $s6Tankey25BaseUITableViewControllerC5coderACSgSo7NSCoderC_tcfcTo + 47
10 Tankey 0x0000000100bcd3fc $s6Tankey19ShareViewControllerC5coderACSgSo7NSCoderC_tcfc + 1260
11 Tankey 0x0000000100bcd4bf $s6Tankey19ShareViewControllerC5coderACSgSo7NSCoderC_tcfcTo + 47
12 UIKitCore 0x000000010f7354f9 -[UIClassSwapper initWithCoder:] + 246
13 UIFoundation 0x000000010d3fe852 UINibDecoderDecodeObjectForValue + 753
14 UIFoundation 0x000000010d3fe554 -[UINibDecoder decodeObjectForKey:] + 251
15 UIKitCore 0x000000010f739b41 -[UIRuntimeConnection initWithCoder:] + 178
16 UIKitCore 0x000000010f739ee2 -[UIRuntimeEventConnection initWithCoder:] + 59
17 UIFoundation 0x000000010d3fe852 UINibDecoderDecodeObjectForValue + 753
18 UIFoundation 0x000000010d3feaf9 UINibDecoderDecodeObjectForValue + 1432
19 UIFoundation 0x000000010d3fe554 -[UINibDecoder decodeObjectForKey:] + 251
20 UIKitCore 0x000000010f7373f1 -[UINib instantiateWithOwner:options:] + 1216
21 UIKitCore 0x000000010fc4fc60 -[UIStoryboard instantiateViewControllerWithIdentifier:] + 181
22 UIKitCore 0x000000010fc507fb -[UIStoryboardSegueTemplate instantiateOrFindDestinationViewControllerWithSender:] + 90
23 UIKitCore 0x000000010fc50a3f -[UIStoryboardSegueTemplate _perform:] + 52
24 UIKitCore 0x000000010f4b854b -[UIViewController performSegueWithIdentifier:sender:] + 99
25 UIKit 0x0000000127bdeec1 -[UIViewControllerAccessibility performSegueWithIdentifier:sender:] + 102
26 Tankey 0x0000000100affb30 $s6Tankey22SettingsViewControllerC05tableC0_14didSelectRowAtySo07UITableC0C_10Foundation9IndexPathVtF + 1280
27 Tankey 0x0000000100b0047e $s6Tankey22SettingsViewControllerC05tableC0_14didSelectRowAtySo07UITableC0C_10Foundation9IndexPathVtFTo + 158
28 UIKitCore 0x000000010fcd2419 -[UITableView _selectRowAtIndexPath:animated:scrollPosition:notifyDelegate:] + 1810
29 UIKitCore 0x000000010fcd262d -[UITableView _userSelectRowAtPendingSelectionIndexPath:] + 337
30 UIKitCore 0x000000010fac2cc9 _runAfterCACommitDeferredBlocks + 318
31 UIKitCore 0x000000010fab2199 _cleanUpAfterCAFlushAndRunDeferredBlocks + 358
32 UIKitCore 0x000000010fadf32b _afterCACommitHandler + 124
33 CoreFoundation 0x0000000107e7e0f7 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 23
34 CoreFoundation 0x0000000107e785be __CFRunLoopDoObservers + 430
35 CoreFoundation 0x0000000107e78c31 __CFRunLoopRun + 1505
36 CoreFoundation 0x0000000107e78302 CFRunLoopRunSpecific + 626
37 GraphicsServices 0x000000010d0a22fe GSEventRunModal + 65
38 UIKitCore 0x000000010fab7ba2 UIApplicationMain + 140
39 Tankey 0x0000000100aee518 main + 72
40 libdyld.dylib 0x000000010958f541 start + 1
41 ??? 0x0000000000000001 0x0 + 1
最佳答案
我注意到 Xcode 在工作应用程序和崩溃应用程序之间的时间内进行了更新。我从 Xcode 10.2 回滚到 10.1,现在崩溃消失了,应用程序工作正常。
回滚是一种解决方法,而不是解决办法。
问题出在我使用的 pod(称为 Inputmask)中,同时问题已在 pod 中修复,现在 Xcode 10.2 一切正常。
关于ios - NSGenericException : This coder requires that replaced objects be returned from initWithCoder,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55395414/