Ios7 iOS 7-正确停止和';清除';调度队列

Ios7 iOS 7-正确停止和';清除';调度队列,ios7,queue,suspend,Ios7,Queue,Suspend,我有一个很长的方法,从服务器下载一组数据和文件,我有一个可访问性类来监控网络连接。我想做的是,如果网络断开,停止队列并“清除”它。当用户单击按钮重试时,它会从头开始。那么,正确的步骤是什么 是吗 在.h文件中 @property (nonatomic) dispatch_queue_t background_q; @property (nonatomic) Reachability *reachMonitor; 在.m文件中 - (void)downloadBigDataAndFiles {

我有一个很长的方法,从服务器下载一组数据和文件,我有一个
可访问性
类来监控网络连接。我想做的是,如果网络断开,停止队列并“清除”它。当用户单击按钮重试时,它会从头开始。那么,正确的步骤是什么

是吗

在.h文件中

@property (nonatomic) dispatch_queue_t background_q;
@property (nonatomic) Reachability *reachMonitor;
在.m文件中

- (void)downloadBigDataAndFiles {
    self.reachMonitor = [Reachability reachabilityForInternetConnection];
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(reachabilityValueChanged:) name:kReachabilityChangedNotification object:nil];
    [reachMonitor startNotifier];

    self.background_q = dispatch_queue_create("backgroundMasterQueue", NULL);
    dispatch_async(background_q, ^{
        // Do whatever
    });
}
断开连接时

- (void)reachabilityValueChanged:(NSNotification *)notification {

    if ([self.reachMonitor currentReachabilityStatus] == NotReachable) {
        if (self.background_q) {              // <- is it necessary?
            dispatch_suspend(self.background_q);
            self.background_q = nil;          // <- is it necessary?
        }
    } else if (([self.reachMonitor currentReachabilityStatus] == ReachableViaWWAN) || ([self.reachMonitor currentReachabilityStatus] == ReachableViaWiFi)) {

        // show up retry button...
    }
}
-(void)可达性值更改:(NSNotification*)通知{
if([self.reachMonitor currentReachabilityStatus]==不可访问){
if(self.background_q){//可能重复的可能重复的可能重复的可能重复的