One can explicitly write @objc on any Swift declaration that can be expressed in Objective-C. @objc相关的参量只能修饰类.类的成员.扩展以及只能被类实现的协议: 下面开列修饰的情况和说明 一.无修饰 NSObject-derived classes no longer infer @objc A declaration within an NSObject-derived class will no
Objective-C entry points https://github.com/apple/swift-evolution/blob/master/proposals/0160-objc-inference.md Before Swift 4, the compiler made some Swift declarations automatically available to Objective-C. For example, if one subclassed from NSObj