使用NSUserDefaults进行swift可选崩溃

时间:2015-01-10 11:40:33

标签: ios swift flurry

我目前在Flurry的特定代码行中收到了一些崩溃报告:

var hasSeenConnectionPrompt = NSUserDefaults.standardUserDefaults().objectForKey("has-seen-connection-prompt") as? Bool ?? false

我无法复制,我在第一次编写代码时假设,如果已经看到连接提示'为零,表达式将返回false。

有人能说清楚为什么会崩溃吗?

堆栈跟踪(xxxxxx是应用名称):

0   xxxxxxxx                            0x0014e628 showConnectionAlertFirstTimeOnly + 3920 (FullProfileView.swift:100)
1   xxxxxxxx                            0x0014d66c onIntroduce + 2140 (FullProfileView.swift:95)
2   CoreFoundation                      0x2be874a1 <redacted> + 12
3   CoreFoundation                      0x2bde393d __CFXNotificationPost + 1784
4   Foundation                          0x2cb139b9 -[NSNotificationCenter postNotificationName:object:userInfo:] + 72
5   Foundation                          0x2cb1851f -[NSNotificationCenter postNotificationName:object:] + 30
6   xxxxxxxx                            0x000f16c8 init + 3520 (MainViewController.swift:86)
7   xxxxxxxx                            0x000f0df4 init + 1260 (MainViewController.swift:0)
8   xxxxxxxx                            0x000f0e54 init + 1356 (MainViewController.swift:0)
9   UIKit                               0x2f636e13 -[UIPresentationController transitionDidFinish:] + 1166
10  UIKit                               0x2f9c12d1 -[_UIFullscreenPresentationController transitionDidFinish:] + 48
11  UIKit                               0x2f639017 <redacted> + 150
12  UIKit                               0x2f47d257 -[_UIViewControllerTransitionContext completeTransition:] + 102
13  UIKit                               0x2f47d0fb -[UITransitionView notifyDidCompleteTransition:] + 294
14  UIKit                               0x2f47cbe9 -[UITransitionView _didCompleteTransition:] + 968
15  UIKit                               0x2f3a0845 -[UIViewAnimationState sendDelegateAnimationDidStop:finished:] + 184
16  UIKit                               0x2f3a0757 -[UIViewAnimationState animationDidStop:finished:] + 66
17  QuartzCore                          0x2ed99599 <redacted> + 236
18  libdispatch.dylib                   0x39adc8b7 <redacted> + 22
19  libdispatch.dylib                   0x39ae00bf __dispatch_main_queue_callback_4CF + 722
20  CoreFoundation                      0x2be94be9 <redacted> + 8
21  CoreFoundation                      0x2be932e9 <redacted> + 1512
22  CoreFoundation                      0x2bde1621 _CFRunLoopRunSpecific + 476
23  CoreFoundation                      0x2bde1433 _CFRunLoopRunInMode + 106
24  GraphicsServices                    0x331900a9 _GSEventRunModal + 136
25  UIKit                               0x2f3cc359 _UIApplicationMain + 1440
26  xxxxxxxx                            0x00125624 init + 2060 (AppDelegate.swift:5)
27  libdyld.dylib                       0x39afcaaf <redacted> + 2

0 个答案:

没有答案