2016-03-29 7 views
0

Meine App stürzt sofort ab, wenn ich versuche, ApplicationshortcutItem zu verwenden, um zu einem View-Controller zu navigieren. Allerdings zeigt meine andere Anwendung Verknüpfung, die in 1 viewcontroller mehr geht, dieses Verhalten nicht. Das Navigieren zum selben View-Controller funktioniert und bringt ihn nicht zum Absturz.Absturz bei Verwendung von ApplicationShortCut SIGTRAP

Mein Absturz:

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 

Methode in Appdelegate die View-Controller zeigen:

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 
      } 
     } 

Hinweis case .Time wird Lauf genannt.

Die Ansicht zeigt eine Tabellenansicht und verwendet eine globale Variable 'pressedYear', die auf dem viewController festgelegt wird, bevor zu dieser navigiert wird. Mein App-Delegat legt auch diese Variable fest.

Wie kann ich dieses Problem beheben? Da ich nicht klar sehen kann, wo es schief geht

Antwort

0

Ich konnte das Problem identifizieren. Da ich vorher keinen Zugriff auf meine Konsole hatte (musste die App beenden), änderte ich mein Schema und stellte sicher, dass ich Zugang zu Debugging-Tools hatte, wenn ich die App zum ersten Mal auf UIApplicationShortcut startete.

ich habe folgendes: i mein Gerät ausgewählt und angeklickt ‚Edit Schema‘ enter image description here

Welche Sie das folgende Ergebnis zeigt: enter image description here

wenn Sie drücken 'Warten auf ausführbare Datei gestartet werden Sie können die App vollständig beenden und sie einfach mit dem angehängten Debugger ausführen.

Es stellte sich heraus habe meine Anwendung stecken, weil eine Variable wurde gesetzt, aber dann wird auf "" magisch eingestellt, die die App Crash gemacht, wie es nicht "" zu einem Int umwandeln könnte. Ich muss in dieses Problem schauen, aber nicht. Es ist repariert!