1.延迟一段时间执行某段代码
[self performSelector:@selector(delayFunctionCode)
withObject:nil
afterDelay:3.0];
2.取消延迟要执行的代码
[NSObject cancelPreviousPerformRequestsWithTarget:self
selector:@selector(delayFunctionCode)
object:nil];
Tip:若有参数,取消时参数要一致(我这里没加参数)