diff --git a/Parse/Internal/PFEventuallyQueue.h b/Parse/Internal/PFEventuallyQueue.h index 7e6a2eb64..dd16becf1 100644 --- a/Parse/Internal/PFEventuallyQueue.h +++ b/Parse/Internal/PFEventuallyQueue.h @@ -67,7 +67,7 @@ extern NSTimeInterval const PFEventuallyQueueDefaultTimeoutRetryInterval; - (void)start NS_REQUIRES_SUPER; - (void)resume NS_REQUIRES_SUPER; - (void)pause NS_REQUIRES_SUPER; -- (void)stop NS_REQUIRES_SUPER; +- (void)terminate NS_REQUIRES_SUPER; - (void)removeAllCommands NS_REQUIRES_SUPER; @end diff --git a/Parse/Internal/PFEventuallyQueue.m b/Parse/Internal/PFEventuallyQueue.m index 68d31aad5..4d43130d1 100644 --- a/Parse/Internal/PFEventuallyQueue.m +++ b/Parse/Internal/PFEventuallyQueue.m @@ -80,10 +80,6 @@ - (instancetype)initWithDataSource:(id)dataSource return self; } -- (void)dealloc { - [self _stopMonitoringNetworkReachability]; -} - ///-------------------------------------- #pragma mark - Enqueueing Commands ///-------------------------------------- @@ -197,7 +193,8 @@ - (void)pause { dispatch_suspend(_processingQueueSource); } -- (void)stop { +- (void)terminate { + [self _stopMonitoringNetworkReachability]; dispatch_source_cancel(_processingQueueSource); } @@ -383,7 +380,6 @@ - (void)_stopMonitoringNetworkReachability { [[PFReachability sharedParseReachability] removeListener:self]; self.monitorsReachability = NO; - self.connected = YES; #endif } @@ -393,9 +389,11 @@ - (void)_stopMonitoringNetworkReachability { /** Manually sets the network connection status. */ - (void)setConnected:(BOOL)connected { + @weakify(self); BFTaskCompletionSource *barrier = [BFTaskCompletionSource taskCompletionSource]; dispatch_async(_processingQueue, ^{ dispatch_sync(_synchronizationQueue, ^{ + @strongify(self); if (self.connected != connected) { _connected = connected; if (connected) { diff --git a/Parse/Internal/PFReachability.m b/Parse/Internal/PFReachability.m index d25f10b88..4aa31b332 100644 --- a/Parse/Internal/PFReachability.m +++ b/Parse/Internal/PFReachability.m @@ -130,7 +130,9 @@ - (void)addListener:(id)listener { } - (void)removeListener:(id)listener { + @weakify(listener); dispatch_barrier_sync(_synchronizationQueue, ^{ + @strongify(listener); [_listenersArray filterUsingPredicate:[NSPredicate predicateWithBlock:^BOOL(id evaluatedObject, NSDictionary *bindings) { id weakObject = [evaluatedObject weakObject]; return (weakObject == nil || weakObject == listener); diff --git a/Parse/Internal/ParseManager.m b/Parse/Internal/ParseManager.m index b6c9d4af3..ac3acc464 100644 --- a/Parse/Internal/ParseManager.m +++ b/Parse/Internal/ParseManager.m @@ -181,8 +181,8 @@ - (PFEventuallyQueue *)eventuallyQueue { if (commandCache.commandCount > 0) { [commandCache removeAllCommands]; } - // we won't need it after stop everything... - [commandCache stop]; + // we won't need it after, terminate... + [commandCache terminate]; } } #endif