首页 > 代码库 > 取消延时函数

取消延时函数

- (void) networkReachabilityDidUpdate:(NetworkReachability*)reachability

{

    [NSObject cancelPreviousPerformRequestsWithTarget:self selector:@selector(reachabilityChanged) object:nil];

    

    [self performSelector:@selector(reachabilityChanged) withObject:nil afterDelay:0.1f];

}

//cancelPreviousPerformRequestsWithTarget是终止上次performSelector的Delay调用

//上面例子是防止在afterDelay时间内重复调用reachabilityChanged