加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

Swift 4.0 报错:Argument of '#selector' refers

发布时间:2020-12-14 06:03:53 所属栏目:百科 来源:网络整理
导读:swfit 4 的新特性 今天编译代码发现了这个问题,查了下,修正很简单在相关类前加: @objcMembers class JKWLoginVC : UIViewController {} 或者在方法名前做修改 @ objc func clickLoginBtn() { } As of Swift 4 you’ll start seeing the error “Argument

swfit 4 的新特性

今天编译代码发现了这个问题,查了下,修正很简单在相关类前加:

@objcMembers
class JKWLoginVC: UIViewController 
{
}

或者在方法名前做修改

@objc func clickLoginBtn() {

    }

As of Swift 4 you’ll start seeing the error “Argument of ‘#selector’ refers to instance method ‘firstPage()’ that is not exposed to Objective-C”,along with the proposed fix of “Add ‘@objc’ to expose this instance method to Objective-C”. What this means is that the Swift method in question isn’t visible to Objective-C,which matters because UIBarButtonItem is Objective-C code.

While adding @objc to individual methods is a working solution,I expect most people will just shrug their shoulders and put @objcMembers before their class – that automatically exposes everything in the class to Objective-C,just like Swift 3 used to. So,modify the class definition to this:

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读