本文介绍了取消[self performSelector:... withObject:nil afterDelay:20];的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在viewDidLoad中使用以下代码调用方法sr,如何在sr将调用的方法之前取消它?
I call method sr in viewDidLoad with below code,how can i cancel it before that method sr will call?
[self performSelector:@selector(sr) withObject:nil afterDelay:20];
推荐答案
[NSObject cancelPreviousPerformRequestsWithTarget:self
selector:@selector(sr)
object:nil];
请阅读文档。 :) 指向取消排队执行请求的方法。
Please read the documentation. :) The documentation for -performSelector:withObject:afterDelay:
points you to the methods for canceling a queued perform request.
这篇关于取消[self performSelector:... withObject:nil afterDelay:20];的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!