diff --git a/Aquasync/Classes/AQAquaSyncPullSyncOperation.m b/Aquasync/Classes/AQAquaSyncPullSyncOperation.m index 068c9c8..3c6b948 100644 --- a/Aquasync/Classes/AQAquaSyncPullSyncOperation.m +++ b/Aquasync/Classes/AQAquaSyncPullSyncOperation.m @@ -50,11 +50,10 @@ - (instancetype)initWithSyncableObjectAggregator:(id # pragma mark - NSOperation - (void)start { - if (self.failTimer) { - [self.failTimer invalidate]; - self.failTimer = nil; - } - + [self performOperation]; +} + +- (void)performOperation { __weak typeof(self) weakSelf = self; NSInteger UST = [self.syncableObjectAggregator UST]; NSString *deviceToken = [self.syncableObjectAggregator deviceToken]; @@ -89,7 +88,7 @@ - (void)didFailWithError:(NSError *)error { self.failCount += 1; NSTimeInterval interval = [self waitForFailCount:self.failCount]; - self.failTimer = [NSTimer scheduledTimerWithTimeInterval:interval target:self selector:@selector(start) userInfo:nil repeats:NO]; + self.failTimer = [NSTimer scheduledTimerWithTimeInterval:interval target:self selector:@selector(performOperation) userInfo:nil repeats:NO]; } - (void)failOperationWithError:(NSError *)error { diff --git a/Aquasync/Classes/AQAquaSyncPushSyncOperation.m b/Aquasync/Classes/AQAquaSyncPushSyncOperation.m index d97076c..c4d0778 100644 --- a/Aquasync/Classes/AQAquaSyncPushSyncOperation.m +++ b/Aquasync/Classes/AQAquaSyncPushSyncOperation.m @@ -48,12 +48,11 @@ - (instancetype)initWithSyncableObjectAggregator:(id # pragma mark - NSOperation -- (void)main { - if (self.failTimer) { - [self.failTimer invalidate]; - self.failTimer = nil; - } - +- (void)start { + [self performOperation]; +} + +- (void)performOperation { AQDeltaPack *deltaPack = [self.syncableObjectAggregator deltaPackForSynchronization]; __weak typeof(self) weakSelf = self; [self.client pushDeltaPack:deltaPack success:^(id response) { @@ -86,7 +85,7 @@ - (void)didFailWithError:(NSError *)error { self.failCount += 1; NSTimeInterval interval = [self waitForFailCount:self.failCount]; - self.failTimer = [NSTimer scheduledTimerWithTimeInterval:interval target:self selector:@selector(start) userInfo:nil repeats:NO]; + self.failTimer = [NSTimer scheduledTimerWithTimeInterval:interval target:self selector:@selector(performOperation) userInfo:nil repeats:NO]; } - (void)failOperationWithError:(NSError *)error {