xcode 取消 [self performSelector:... withObject:nil afterDelay:20];
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/5055869/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Cancel [self performSelector:... withObject:nil afterDelay:20];
提问by SajjadZare
I call method sr in viewDidLoad with below code,how can i cancel it before that method sr will call?
我使用以下代码在 viewDidLoad 中调用方法 sr,如何在该方法 sr 调用之前取消它?
[self performSelector:@selector(sr) withObject:nil afterDelay:20];
回答by CIFilter
[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.
请阅读文档。:) 文档-performSelector:withObject:afterDelay:
指向您取消排队执行请求的方法。