DISPATCH TIMER

/*
    __block void (^callback)() = [^{
       
        float second = 2.0;
        bool _stop = NO;
        if(_stop) {
            NSLog(@"all done");
            callback = nil; // break retain cycle
        } else {
            NSLog(@"still going");
            NSMutableDictionary *dic = [[NSMutableDictionary alloc]init];
       
            [dic setObject:object forKey:key];
           
           
            [_service listMessages:^(id response, NSError *error) {
                //获取主线程,更新界面
                if (error) {
                    //show error
                }else{
                    获取数据
                       
                    }
                    dispatch_async(dispatch_get_main_queue(), ^{
                        //更新界面
                        [table reloadData];
                        [self scrollTableToFoot];
                    });
                }
               
               
            } parameters:dic];
            dispatch_after(dispatch_time(DISPATCH_TIME_NOW, second * NSEC_PER_SEC),
                           dispatch_get_main_queue(),
                           callback);
        }
    } copy];
   
    dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 2.0 * NSEC_PER_SEC),
                   dispatch_get_main_queue(),
                   callback);
     */

猜你喜欢

转载自lizhuang.iteye.com/blog/2066403
今日推荐