EXC_SOFTWARE / UNCAUGHT_NS_EXCEPTION

时间:2016-12-11 06:17:02

标签: ios swift crash-reports

我在生活应用程序中发生了崩溃,我无法在我的设备上重现。我无法弄清楚是什么原因造成的。我研究了崩溃报告,但似乎无法理解造成这种情况的原因。

1 CoreFoundation __exceptionPreprocess + 1241536
2 libobjc.A.dylib objc_exception_throw + 34136
3 CoreFoundation -[NSObject(NSObject) doesNotRecognizeSelector:] + 1270388
4 CoreFoundation ___forwarding___ + 1258100
5 CoreFoundation _CF_forwarding_prep_0 + 185752
6 GLKit -[GLKViewController setPaused:] + 144836
7 GLKit -[GLKViewController _pauseByNotification] + 142828
8 CoreFoundation __CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER__ + 823848
9 CoreFoundation _CFXRegistrationPost + 821548
10 CoreFoundation ___CFXNotificationPost_block_invoke + 820904
11 CoreFoundation -[_CFXNotificationRegistrar find:object:observer:enumerator:] + 1276824
12 CoreFoundation _CFXNotificationPost + 44016
13 Foundation -[NSNotificationCenter postNotificationName:object:userInfo:] + 26152
14 UIKit -[UIApplication _deactivateForReason:notify:] + 491392
15 UIKit __61-[UIApplication _sceneSettingsPreLifecycleEventDiffInspector]_block_invoke + 2711892
16 FrontBoardServices __52-[FBSSettingsDiffInspector inspectDiff:withContext:]_block_invoke.27 + 144868
17 Foundation __NSIndexSetEnumerate + 788368
18 BaseBoard -[BSSettingsDiff inspectChangesWithBlock:] + 208636
19 FrontBoardServices -[FBSSettingsDiff inspectOtherChangesWithBlock:] + 120484
20 FrontBoardServices -[FBSSettingsDiffInspector inspectDiff:withContext:] + 144320
21 UIKit __70-[UIApplication scene:didUpdateWithDiff:transitionContext:completion:]_block_invoke + 2717116
22 UIKit -[UIApplication scene:didUpdateWithDiff:transitionContext:completion:] + 2716256
23 UIKit -[UIApplicationSceneClientAgent scene:handleEvent:withCompletion:] + 6065056
24 FrontBoardServices __80-[FBSSceneImpl updater:didUpdateSettings:withDiff:transitionContext:completion:]_block_invoke.376 + 52104
25 FrontBoardServices __FBSSERIALQUEUE_IS_CALLING_OUT_TO_A_BLOCK__ + 239800
26 FrontBoardServices -[FBSSerialQueue _performNext] + 239396
27 FrontBoardServices -[FBSSerialQueue _performNextFromRunLoopSource] + 240332
28 CoreFoundation __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 905844
29 CoreFoundation __CFRunLoopDoSources0 + 904124
30 CoreFoundation __CFRunLoopRun + 894908
31 CoreFoundation CFRunLoopRunSpecific + 36932
32 GraphicsServices GSEventRunModal + 49556
33 UIKit -[UIApplication _run] + 504568
34 UIKit UIApplicationMain + 483376
35 XXX main (XXXViewController.swift:14)
36 libdyld.dylib
start + 17844

第35行(仅提及我编写的代码)是XXXViewController类定义行:

class XXXViewController: UIViewController, UITableViewDelegate, UITableViewDataSource {
...
}

这个ViewController调用一个观察者,这似乎是个问题。我确保删除Viewintrollers中所有在deinit函数中使用它们的观察者。

deinit {
    NSNotificationCenter.defaultCenter().removeObserver(self)
}

有没有人知道还有什么可能出错?

更新: 我像这样注册观察者ini init()(我应该使用viewDidLoad吗?):

NSNotificationCenter.defaultCenter().addObserver(self, selector:#selector(YViewController.dataUpdate(_:)), name: "DataChanged", object: nil)

并发布这样的通知:

NSNotificationCenter.defaultCenter().postNotificationName("DataChanged", object: self, userInfo: nil)

YViewController dataUpdate如下:

func dataUpdate(notification: NSNotification) {
    //Some stuff is done
}

我现在使用swift 2.0,崩溃发生在iOS版本10.0.1-10.1.1

1 个答案:

答案 0 :(得分:0)

以防万一有人落在这里。问题是我覆盖了GLKViewController的基本视图,而不是将新视图添加为子视图。当我切换到Crashlytics时,这一点很容易弄清楚,它提供了有关崩溃的更多信息。