2016-05-02 7 views
0

Ich wurde von Crashlytics abgestürzt. Wahrscheinlich ist es mit weakSelf verbunden.Ich kann einen Absturz nicht verstehen.

Crashed: com.apple.main-thread 
EXC_BREAKPOINT 0x000000000defe 

0 libobjc.A.dylib    0x224aea44 _objc_trap() 
1 libobjc.A.dylib    0x224aeaa9 _objc_inform + 70 
2 libobjc.A.dylib    0x224c8413 weak_register_no_lock + 210 
3 libobjc.A.dylib    0x224c8993 objc_initWeak + 130 
4 GPS_______appLite    0xd77b1 -[ModuleView observeValueForKeyPath:ofObject:change:context:] (ModuleView.m:232) 
5 GPS_______appLite    0xd9287 -[ModuleSpeedometerView observeValueForKeyPath:ofObject:change:context:] (ModuleSpeedometerView.m:198) 
6 Foundation      0x2349aa91 NSKVONotify + 52 
7 Foundation      0x23479bef NSKeyValueNotifyObserver + 286 
8 Foundation      0x23479847 NSKeyValueDidChange + 346 
9 Foundation      0x23466599 -[NSObject(NSKeyValueObserverNotification) didChangeValueForKey:] + 96 
10 GPS_______appLite    0x12c393 -[GPSTracker private_updateCurrentStatisticsWithLocation:] (GPSTracker.mm:1887) 
11 GPS_______appLite    0x12c1b9 -[GPSTracker private_addLocationToHistory:] (GPSTracker.mm:1870) 
12 GPS_______appLite    0x12c6af -[GPSTracker private_processNewLocation:fromManager:] (GPSTracker.mm:1938) 
13 GPS_______appLite    0x12c88b -[GPSTracker locationManager:didUpdateLocations:] (GPSTracker.mm:1953) 
14 CoreLocation     0x28c5c493 (null) + 25830 
15 CoreLocation     0x28c5765b (null) + 5806 
16 CoreLocation     0x28c50725 (null) + 988 
17 CoreFoundation     0x22cd5d91 __CFRUNLOOP_IS_CALLING_OUT_TO_A_BLOCK__ + 12 
18 CoreFoundation     0x22cd584d __CFRunLoopDoBlocks + 216 
19 CoreFoundation     0x22cd41bf __CFRunLoopRun + 1806 
20 CoreFoundation     0x22c232e9 CFRunLoopRunSpecific + 520 
21 CoreFoundation     0x22c230d5 CFRunLoopRunInMode + 108 
22 GraphicsServices    0x24213ac9 GSEventRunModal + 160 
23 UIKit       0x272e80b9 UIApplicationMain + 144 
24 GPS_______appLite    0x10adc7 main (main.m:15) 
25 libdispatch.dylib    0x228cb873 (Missing) 

und Code

//ModuleView class 
- (void)observeValueForKeyPath:(NSString *)keyPath 
        ofObject:(id)object 
        change:(NSDictionary *)change 
        context:(void *)context 
{ 
if ([object isKindOfClass:[GPSTracker class]]) 
{ 
    __weak GPSTracker *tracker = (GPSTracker *)object; 
    __weak __typeof__(self) weakSelf = self; 

    dispatch_async(dispatch_get_main_queue(), ^{ 
     if ([keyPath isEqualToString:NSStringFromSelector(@selector(trackerMode))]) 
     { 
      [weakSelf trackerStateChanged]; 
     } 
     else if ([keyPath isEqualToString:NSStringFromSelector(@selector(currentStatistics))]) 
     { 
      id oldValue = [change objectForKey:NSKeyValueChangeOldKey]; 
      if (!oldValue 
       || [oldValue isKindOfClass:[NSNull class]]) 
      { 
       // If statistics instance has been initialized 
       if (!weakSelf.shouldIgnoreUpdates) 
       { 
        [tracker.currentStatistics.time addUniqueObserver:weakSelf 
                  forKeyPath:NSStringFromSelector(@selector(elapsed)) 
                   options:NSKeyValueObservingOptionNew]; 
       } 
      } 

      [weakSelf trackerUpdate]; 
     } 
    }); 
} 
else if ([object isKindOfClass:[GPSTrackerTimeStatistics class]]) 
{ 
    __weak __typeof__(self) weakSelf = self; 
    dispatch_async(dispatch_get_main_queue(), ^{ 
     [weakSelf timerUpdate]; 
    }); 
} 
} 
+0

Zeigen Sie an, welche Zeile des Codes Zeile 232 von ModuleView.m ist. – rmaddy

+0

rmaddy, __ weak __typeof __ (selbst) weakself = self; – Voloda2

+0

Ich weiß nichts über den Absturz, aber Sie müssen hier kein '__weak Self' verwenden, da Sie keinen Retain-Zyklus haben. Ihr ModuleView hat keinen starken Zeiger auf den Block, so dass Sie "self" sicher im Block anstelle von "weakSelf" übergeben können. – dirkgroten

Antwort

0

für freigegebene Version Sie Abstürze und Codezeile sehen können,

in xCode: Window-> Organiser-> Crashes

und wählen Sie App und Version von linken Panels

versuchen "Ausnahme Breakpoint"

Exception-Haltepunkt hinzufügen automatisch Breakpoint Linie Absturz führen, und Sie können das Problem

hinzufügen Exception Breakpoint- sehen:

in xCode: Top-Menü -> Debug -> Haltepunkte -> Anlegen Ausnahme Breakpoint- ...

und erneut ausführen