我花了时间调试我的代码,希望有一个解决方案,但只有当我没有连接到调试器时才会发生这种崩溃。FireBase工作者崩溃failWithError
我已经设置了一个Firebase Singleton,管理四个不同路径的firebase。各火力是设置使用的代码片段是这样的:
-(void)connectFirebaseForMatch:(NSNumber*)matchId{
if(status == FireBaseStatusConnected){
if(matchFirebase){
[matchFirebase removeAllObservers];
matchFirebase = nil;
}
NSString *baseURL = [NSString stringWithFormat:@"%@matches/%@",kFirechatNS,matchId];
matchFirebase = [[Firebase alloc] initWithUrl:baseURL];
if(!matchFirebase){
return;
}
__weak FirebaseClient *bSelf = self;
void(^messages_block_with_connection)(FDataSnapshot*) = ^(FDataSnapshot* snapshot){
if(snapshot){
[[LACoreDataStore sharedStore] updateMessageWithSnapshot:snapshot forMatchId:matchId dateFormatter:writingDateFormatter withCompletion:^(BOOL newMessages, NSNumber *matchIdFromBlock, NSError *error) {
//Tell Message View to Refresh TableView using Notification Center
[[NSObject class] cancelPreviousPerformRequestsWithTarget:bSelf selector:@selector(reloadMessagesForMatch:) object:matchIdFromBlock];
[bSelf performSelector:@selector(reloadMessagesForMatch:) withObject:matchIdFromBlock afterDelay:.1];
}];
}
};
void(^no_messages_block_with_connection)(FDataSnapshot*) = ^(FDataSnapshot* snapshot){
//Tell Message View to Refresh TableView using Notification Center
[bSelf performSelector:@selector(reloadMessagesForMatch:) withObject:matchId afterDelay:.05];
};
[matchFirebase observeEventType:FEventTypeChildAdded withBlock:messages_block_with_connection];
[matchFirebase observeSingleEventOfType:FEventTypeValue withBlock:no_messages_block_with_connection];
NSLog(@"Registered Messaging View with Firebase: %@",baseURL);
}
}
各火力简单地读取来自火力新数据到核心数据,并使用该通知中心刷新取其观点是必要的。
一切似乎都在使用的应用程序工作正常,但在一天左右后,我得到了火力地堡的工人此崩溃,我无法找到来源:
FSRWebSocket.m line 716
__31-[FSRWebSocket _failWithError:]_block_invoke_2
从Crashlytics:
Crashed: FirebaseWorker
EXC_BAD_ACCESS KERN_INVALID_ADDRESS at 0xb0000010
非常感谢您的帮助:)
如果你正在使用通知中心,那么你应该检查是否所有注册事件的观察者都自己注销,例如在dealloc方法中(我假设它们是ViewControllers) – MP23