为什么performSelector不存在于swift中 [英] why is performSelector not present in swift

查看:134
本文介绍了为什么performSelector不存在于swift中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

显然以下内容在swift中不再可用:

apparently the following is not available in swift anymore:

[self performSelector:@selector(onFlip) withObject:nil afterDelay:0.3];

如果以下情况仍然存在,为什么会这样:

why is this the case if the following is still present:

NSObject.cancelPreviousPerformRequestsWithTarget(self, selector: singleTapSelector, object: nil)

nsobject.cancel不能与performSelector一起使用吗?为什么有取消功能而不是执行功能?

doesn't nsobject.cancel work with performSelector? why have the cancel functionality but not the perform functionality?

推荐答案

使用

NSTimer.scheduledTimerWithTimeInterval(delay, target: self, selector: "onFlip", userInfo: nil, repeats: false)

。不知道为什么另一个不可用。

instead. No idea why the other one is not available.

这篇关于为什么performSelector不存在于swift中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆