Protocol是一个在 Objective-C 运行时中定义的类,代表一个 Objective-C 协议。例子:
let p = objc_getProtocol("NSObject")!
print(p.dynamicType) // Output: "Protocol"
Run Code Online (Sandbox Code Playgroud)
objc_getProtocol 被声明为
/**
* Returns a specified protocol.
*
* @param name The name of a protocol.
*
* @return The protocol named \e name, or \c NULL if no protocol named \e name could be found.
*
* @note This function acquires the runtime lock.
*/
@available(OSX 10.5, *)
public func objc_getProtocol(name: UnsafePointer<Int8>) -> Protocol!
Run Code Online (Sandbox Code Playgroud)
并被Protocol声明为
// typedef Protocol is here:
// All methods of class Protocol are unavailable.
// Use the functions in objc/runtime.h instead.
@available(OSX 10.0, *)
public class Protocol {
}
Run Code Online (Sandbox Code Playgroud)
底层的 Objective-C 定义可以在<objc/Protocol.h>
和 中
找到
<objc/runtime.h>。
| 归档时间: |
|
| 查看次数: |
244 次 |
| 最近记录: |