Crashlytics 报告了此崩溃:
0 libobjc.A.dylib _objc_trap() + 18446744073709552000
1 libobjc.A.dylib _objc_fatal + 71
2 libobjc.A.dylib append_referrer_no_lock(weak_referrer_array_t*, objc_object**)
3 libobjc.A.dylib objc_storeWeak + 120
4 MyApp CloudSyncButton.m line 58 -[CloudSyncButton observeValueForKeyPath:ofObject:change:context:]
5 ....
有问题的代码:
-(void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context {
CloudSyncButton* __weak weakSelf = self; //<---crashed here
if([keyPath isEqualToString:kCloudSyncingKVO]) {
dispatch_async(dispatch_get_main_queue(), ^{
CloudSyncButton* localSelf = weakSelf;
[localSelf refreshCloudSyncIcon];
});
}
}
我需要帮助来理解为什么会崩溃,以及我将来可以做些什么来避免它。这是我第一次看到这样的崩溃,所以我想知道这是否是侥幸?