我一直在使用AFNetworking同步信息,发现它在我申请时向服务器发送了多个请求,multithreading但我只执行了一个请求语句。
可以使用嗅探器应用程序跟踪此问题,因为Xcode debugger无法跟踪请求。
另外,我注意到当互联网连接速度变慢时会发生这种情况。
这是我执行的一些代码
开始同步
- (void)SyncFull
{
[[NSNotificationCenter defaultCenter] addObserver:self 选择器:@selector(FinishSyncFull:)
名称:@“FinishSyncFull”对象:无];
[[NSNotificationCenter defaultCenter] addObserver:self 选择器:@selector(RemoveNotificacions:) name:@"RemoveNotificacions" object:nil];
[[PivotService getInstance] 同步];
}
继续同步的通知
-(void)FinishSyncFull:(NSNotification*) 通知
{
[[NSNotificationCenter defaultCenter] removeObserver:self name:@"FinishSyncFull" object:nil];
if ([SyncManager getInstance] mustSync])
{
[[FMDBHelper getInstance] RemoveDataFromTable:@"SyncInfo"];
[[FMDBHelper getInstance] RemoveDataFromTable:@"SyncDetails"];
[self startSyncFull];
}
}
功能说明startSyncFull:
- (void)startSyncFull
{
[[ServiceEntity1 getInstance] sync];
[[ServiceEntity2 getInstance] sync];
[[ServiceEntity3 getInstance] sync];
(...)
}