performSelector 与 cancelPreviousPerformRequestsWithTarget

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

[self performSelector:@selector(clickHandle) withObject:nil afterDelay:3];

这两个方法可以一起使用.

1 performSelector    3秒钟之后 执行方法

2 cancelPreviousPerformRequestsWithTarget:取消performSelector方法注册过的方法,就是说当上面这个方法正在运行,比如希望3秒钟之后执行某一个方法,但是没到3秒钟的情况下 又想取消performSelector,就是用cancelPreviousPerformRequestsWithTarget方法来实现的

你可能感兴趣的:(performSelector 与 cancelPreviousPerformRequestsWithTarget)