2016-04-08 7 views
1

Dies ist das Crash-Protokoll I von Crashlytics bekam:Swift Crash-Berichte machen keinen Sinn für mich

Thread : Crashed: com.apple.main-thread 
0 Trenìt!      0x1000b93e4 SearchHistoryProvider.getMostRecentStations(Int) -> [String] (SearchHistoryProvider.swift) 
1 Trenìt!      0x10007985c specialized MasterViewController.onTouchedTextField(UITextField) ->() (MasterViewController.swift:265) 
2 Trenìt!      0x100075414 @objc MasterViewController.onTouchedTextField(UITextField) ->() (MasterViewController.swift) 
3 UIKit       0x186fa0ad0 -[UIApplication sendAction:to:from:forEvent:] + 100 
4 UIKit       0x186fa0a4c -[UIControl sendAction:to:forEvent:] + 80 
5 UIKit       0x186f88740 -[UIControl _sendActionsForEvents:withEvent:] + 436 
6 UIKit       0x186fa9248 -[UIControl touchesBegan:withEvent:] + 400 
7 UIKit       0x186f9fdc0 -[UIWindow _sendTouchesForEvent:] + 376 
8 UIKit       0x186f98b08 -[UIWindow sendEvent:] + 784 
9 UIKit       0x186f68f4c -[UIApplication sendEvent:] + 248 
10 UIKit       0x186f67528 _UIApplicationHandleEventQueue + 6568 
11 CoreFoundation     0x181dd5124 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 24 
12 CoreFoundation     0x181dd4bb8 __CFRunLoopDoSources0 + 540 
13 CoreFoundation     0x181dd28b8 __CFRunLoopRun + 724 
14 CoreFoundation     0x181cfcd10 CFRunLoopRunSpecific + 384 
15 GraphicsServices    0x1835e4088 GSEventRunModal + 180 
16 UIKit       0x186fd1f70 UIApplicationMain + 204 
17 Trenìt!      0x10009b2fc main (AppDelegate.swift:14)``` 
(edited) 

und dies ist mein Code:

MasterViewController.swift:

263 func showRecentStations(textField: UITextField) { 
264  textField.text = "" 
265  suggestionStations = masterContainerManager!.homeController?.searchHistoryProvider?.getMostRecentStations(10) 
266  updateStationsTable(textField) 
267 } 

SearchHistoryProvider.swift

func getMostRecentStations (maxSize : Int) -> [String] { 
    let stationsByOldestArray = getRecentStationsByOldest() 
    let stations = NSMutableOrderedSet() 
    for i in (0...(stationsByOldestArray.count-1)).reverse() { 
     stations.addObject(stationsByOldestArray[i].depStation) 
     if stations.count==maxSize { 
      return stations.array as! [String] 
     } 
     stations.addObject(stationsByOldestArray[i].arrStation) 
     if stations.count==maxSize { 
      return stations.array as! [String] 
     } 
    } 
    return stations.array as! [String] 
} 

Kann jemand verstehen, worum es bei dem Absturz geht?

+0

Verwenden Sie besser 'Ausnahme Breakpoint hinzufügen' für alle. Es wird einfacher zu verfolgen. – Ryan

+0

Dies ist ein Fehler in der Live-Version, die ich nicht reproduzieren kann. Wie kann ich verstehen, was der Fehler ist? –

+0

Es ist schwer zu sagen, was genau der Grund ist. Ich glaube, dass 'Crashlytics', das' Fabric' ist, nun mehr Details zur Verfügung stellt, wenn du 'dsym' per Skript hochlädst, während sie geführt werden. – Ryan

Antwort

1

fand ich den Fehler:

bei stationsByOldestArray.count von 0

die for-Schleife

for i in (0...-1).reverse()

gewesen wäre ich es behoben, indem die Schleife als

Umschreiben

for i in (0..<stationsByOldestArray.count).reverse()

Aber ich denke, die Swift-Absturzberichte sind oft hoffnungslos wenig hilfreich!