Swift @objcMembers

 

使用@objcMembers关键字,将类中的所有方法暴露给Objc (效果等同于为所有方法加上@objc)。

 

 

示例代码:

@objcMembers class MyController: UIViewController {
    func login() {

    }
}

 

等同于为login方法加上@objc关键字。

 

 

 

参考链接:

https://www.hackingwithswift.com/example-code/language/what-is-the-objcmembers-attribute

http://biuer.club/2018/05/08/Swift3、4中的-objc、-objcMembers和dynamic/

https://docs.swift.org/swift-book/ReferenceManual/Attributes.html

posted @ 2018-12-21 17:26  Ficow  阅读(1155)  评论(0编辑  收藏  举报