Swift 使用ApplicationShortCut SIGTRAP时崩溃

Swift 使用ApplicationShortCut SIGTRAP时崩溃,swift,crash,crash-reports,Swift,Crash,Crash Reports,当我试图使用ApplicationshortcutItem导航到视图控制器时,我的应用程序立即崩溃。 但是,我的另一个应用程序快捷方式(位于1viewcontrollermore中)没有显示这种行为。 导航到同一视图控制器可以工作,但不会使其崩溃 我的崩溃: Thread 0 name: Dispatch queue: com.apple.main-thread Thread 0 Crashed: 0 libswiftCore.dylib 0x0000000100

当我试图使用
ApplicationshortcutItem
导航到视图控制器时,我的应用程序立即崩溃。 但是,我的另一个应用程序快捷方式(位于1
viewcontroller
more中)没有显示这种行为。 导航到同一视图控制器可以工作,但不会使其崩溃

我的崩溃:

Thread 0 name:  Dispatch queue: com.apple.main-thread
Thread 0 Crashed:
0   libswiftCore.dylib              0x000000010064e5dc 0x100510000 + 1304028
1   PayDay!                         0x000000010011166c 0x1000e0000 + 202348
2   PayDay!                         0x00000001001126a4 0x1000e0000 + 206500
3   UIKit                           0x0000000186c42f40 -[UITableView _createPreparedCellForGlobalRow:withIndexPath:willDisplay:] + 692
4   UIKit                           0x0000000186c430a8 -[UITableView _createPreparedCellForGlobalRow:willDisplay:] + 80
5   UIKit                           0x0000000186c321a8 -[UITableView _updateVisibleCellsNow:isRecursive:] + 2360
6   UIKit                           0x0000000186c47b74 -[UITableView _performWithCachedTraitCollection:] + 104
7   UIKit                           0x00000001869d87ac -[UITableView layoutSubviews] + 176
8   UIKit                           0x00000001868e80e4 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 656
9   QuartzCore                      0x000000018428ea28 -[CALayer layoutSublayers] + 148
10  QuartzCore                      0x0000000184289634 CA::Layer::layout_if_needed(CA::Transaction*) + 292
11  UIKit                           0x00000001868fefa4 -[UIView(Hierarchy) layoutBelowIfNeeded] + 924
12  UIKit                           0x00000001869ad57c -[UINavigationController _layoutViewController:] + 1196
13  UIKit                           0x00000001869aaf54 -[UINavigationController _layoutTopViewController] + 228
14  UIKit                           0x00000001869c3cc0 -[UINavigationController navigationTransitionView:didEndTransition:fromView:toView:] + 728
15  UIKit                           0x00000001869c39ac -[UINavigationTransitionView _notifyDelegateTransitionDidStopWithContext:] + 416
16  UIKit                           0x00000001869c36b4 -[UINavigationTransitionView _cleanupTransition] + 744
17  UIKit                           0x0000000186927b10 -[UIViewAnimationState sendDelegateAnimationDidStop:finished:] + 312
18  UIKit                           0x0000000186925d8c +[UIViewAnimationState popAnimationState] + 324
19  UIKit                           0x00000001869b711c -[UINavigationTransitionView transition:fromView:toView:] + 1792
20  UIKit                           0x00000001869acc30 -[UINavigationController _startTransition:fromViewController:toViewController:] + 2696
21  UIKit                           0x00000001869abddc -[UINavigationController _startDeferredTransitionIfNeeded:] + 868
22  UIKit                           0x00000001869aba04 -[UINavigationController __viewWillLayoutSubviews] + 60
23  UIKit                           0x00000001869ab96c -[UILayoutContainerView layoutSubviews] + 208
24  UIKit                           0x00000001868e80e4 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 656
25  QuartzCore                      0x000000018428ea28 -[CALayer layoutSublayers] + 148
26  QuartzCore                      0x0000000184289634 CA::Layer::layout_if_needed(CA::Transaction*) + 292
27  QuartzCore                      0x00000001842894f4 CA::Layer::layout_and_display_if_needed(CA::Transaction*) + 32
28  QuartzCore                      0x0000000184288b24 CA::Context::commit_transaction(CA::Transaction*) + 252
29  QuartzCore                      0x000000018428886c CA::Transaction::commit() + 512
30  QuartzCore                      0x0000000184281dd8 CA::Transaction::observer_callback(__CFRunLoopObserver*, unsigned long, void*) + 80
31  CoreFoundation                  0x00000001817587b0 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 32
32  CoreFoundation                  0x0000000181756554 __CFRunLoopDoObservers + 372
33  CoreFoundation                  0x0000000181680d30 CFRunLoopRunSpecific + 416
34  UIKit                           0x000000018695b834 -[UIApplication _run] + 460
35  UIKit                           0x0000000186955f70 UIApplicationMain + 204
36  PayDay!                         0x00000001001262dc 0x1000e0000 + 287452
37  libdyld.dylib                   0x000000018121e8b8 start + 4
方法,以显示视图控制器:

if let rootViewController = window?.rootViewController, let shortcutItemType = DGShortcutItemType(shortcutItem: shortcutItem) {
            rootViewController.dismissViewControllerAnimated(false, completion: nil)
            switch shortcutItemType {
            case .Message:
                let storyboard = UIStoryboard(name: "Main", bundle: nil)
                let rootTabbarController = self.window?.rootViewController as! UITabBarController
                let firstNav = storyboard.instantiateViewControllerWithIdentifier("NavController") as! UINavigationController
                rootTabbarController.viewControllers![0] = firstNav
                let VC1 = storyboard.instantiateViewControllerWithIdentifier("PeriodeView")
                let VC2 = storyboard.instantiateViewControllerWithIdentifier("weekViewController")
                let VC3 = storyboard.instantiateViewControllerWithIdentifier("timesInsertViewController")
                firstNav.viewControllers.insert(VC1, atIndex: 1)
                firstNav.viewControllers.insert(VC2, atIndex: 2)
                firstNav.pushViewController(VC3, animated: false)
                break
            case .Time:
                let storyboard = UIStoryboard(name: "Main", bundle: nil)
                let rootTabbarController = self.window?.rootViewController as! UITabBarController
                let firstNav = storyboard.instantiateViewControllerWithIdentifier("NavController") as! UINavigationController
                rootTabbarController.viewControllers![0] = firstNav
                let VC1 = storyboard.instantiateViewControllerWithIdentifier("PeriodeView")
                let VC2 = storyboard.instantiateViewControllerWithIdentifier("weekViewController")
                firstNav.viewControllers.insert(VC1, atIndex: 1)
                firstNav.pushViewController(VC2, animated: false)

                // Display an alert indicating the shortcut selected from the home screen.
                break
            }
        }
注意
case.Time
正在被调用

该视图显示tableview,并使用全局变量“pressedYear”,该变量在导航到viewController之前在viewController上设置。 我的应用程序委托也设置了这个非常相同的变量


如何解决此问题?由于我无法清楚地看到哪里出了问题,我已经能够确定问题所在。 由于我以前没有访问控制台的权限(不得不终止应用程序),因此我更改了方案,并确保在UIApplicationShortcut上首次启动应用程序时,我确实有访问调试工具的权限

我做了以下工作: 我选择了我的设备并单击了“编辑方案”

这将向您显示以下结果:

如果你按下“等待可执行文件被启动”,你可以完全关闭应用程序,只需在安装了调试器的情况下运行它

原来我的应用程序被卡住了,因为设置了一个变量,然后神奇地设置为
,这使得应用程序崩溃,因为它无法将
转换为
Int
。 我将不得不研究这个问题,但不是为了。它是固定的