我的Today扩展视图控制器中有以下代码:
let defaults: NSUserDefaults? = NSUserDefaults(suiteName: kAppGroupName)
if defaults != nil {
if myNsManagedObject != nil {
defaults!.setDouble(myNsManagedObject!.doubleField, forKey: "key_name")
}
}
但是,我正在收到有关setDouble
电话的崩溃报告,但我自己无法重现。什么可能导致以下崩溃?
Crashed: com.apple.main-thread EXC_BREAKPOINT 0x00000001000b1da4 Crashed: com.apple.main-thread 0 today 0x1000b1da4 specialized TodayViewController.updateViews(NWXForecastRecord?) -> () (TodayViewController.swift:249) 1 today 0x1000ad5e0 @objc TodayViewController.viewWillAppear(Bool) -> () (TodayViewController.swift) 2 UIKit 0x186cd1374 -[UIViewController _setViewAppearState:isAnimating:] + 628 3 UIKit 0x186cd10e8 -[UIViewController __viewWillAppear:] + 156 4 NotificationCenter 0x19443aaa0 -[_NCWidgetViewController viewWillAppear:] + 88 5 UIKit 0x186cd1374 -[UIViewController _setViewAppearState:isAnimating:] + 628 6 UIKit 0x186cd10e8 -[UIViewController __viewWillAppear:] + 156 7 UIKit 0x1874d8be8 -[_UIViewServiceViewControllerOperator __hostViewWillAppear:inInterfaceOrientation:traitCollection:statusBarHeight:underlapsStatusBar:completionHandler:] + 568 8 CoreFoundation 0x181b60a60 __invoking___ + 144 9 CoreFoundation 0x181a58488 -[NSInvocation invoke] + 284 10 CoreFoundation 0x181a5cdb0 -[NSInvocation invokeWithTarget:] + 60 11 UIKit 0x1875acbcc -[_UIViewServiceImplicitAnimationDecodingProxy forwardInvocation:] + 268 12 CoreFoundation 0x181b5ea1c ___forwarding___ + 408 13 CoreFoundation 0x181a5cc5c _CF_forwarding_prep_0 + 92 14 CoreFoundation 0x181b60a60 __invoking___ + 144 15 CoreFoundation 0x181a58488 -[NSInvocation invoke] + 284 16 CoreFoundation 0x181a5cdb0 -[NSInvocation invokeWithTarget:] + 60 17 UIKit 0x18752222c -[_UIQueueingProxy forwardInvocation:] + 372 18 CoreFoundation 0x181b5ea1c ___forwarding___ + 408 19 CoreFoundation 0x181a5cc5c _CF_forwarding_prep_0 + 92 20 CoreFoundation 0x181b60a60 __invoking___ + 144 21 CoreFoundation 0x181a58488 -[NSInvocation invoke] + 284 22 CoreFoundation 0x181a5cdb0 -[NSInvocation invokeWithTarget:] + 60 23 CoreFoundation 0x181b5ea1c ___forwarding___ + 408 24 CoreFoundation 0x181a5cc5c _CF_forwarding_prep_0 + 92 25 CoreFoundation 0x181b60a60 __invoking___ + 144 26 CoreFoundation 0x181a58488 -[NSInvocation invoke] + 284 27 FrontBoardServices 0x1834fb7ac __FBSSERIALQUEUE_IS_CALLING_OUT_TO_A_BLOCK__ + 36 28 FrontBoardServices 0x1834fb618 -[FBSSerialQueue _performNext] + 168 29 FrontBoardServices 0x1834fb9c8 -[FBSSerialQueue _performNextFromRunLoopSource] + 56 30 CoreFoundation 0x181b1109c __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 24 31 CoreFoundation 0x181b10b30 __CFRunLoopDoSources0 + 540 32 CoreFoundation 0x181b0e830 __CFRunLoopRun + 724 33 CoreFoundation 0x181a38c50 CFRunLoopRunSpecific + 384 34 GraphicsServices 0x183320088 GSEventRunModal + 180 35 UIKit 0x186d22088 UIApplicationMain + 204 36 libxpc.dylib 0x1817fcce0 _xpc_objc_main + 784 37 libxpc.dylib 0x1817fe9dc xpc_main + 200 38 Foundation 0x18261bd60 service_connection_handler + 170 39 PlugInKit 0x188e5ec48 -[PKService run] + 544 40 PlugInKit 0x188e5e8dc +[PKService main] + 56 41 PlugInKit 0x188e5ec6c +[PKService _defaultRun:arguments:] + 20 42 libextension.dylib 0x18242e058 NSExtensionMain + 64 43 libdispatch.dylib 0x1815d68b8 (Missing)