NSObject中取消selector的方法
2017-02-24 本文已影响24人
饭后的甜点_
[self performSelector:@selector(test:)withObject:nil afterDelay:1];
//延时1秒执行 方法将会在当前线程的Run Loop中根据afterDelay参数创建一个Timer
[NSObject cancelPreviousPerformRequestsWithTarget:self];
//取消selector 方法
[self performSelector:@selector(test:)withObject:nil afterDelay:1];
[NSObject cancelPreviousPerformRequestsWithTarget:self selector:@selector(test:) object:nil];