Swift 运行时一些方法

一、 class_getProperty 方法

  class_getProperty(cls: AnyClass?, name: UnsafePointer<Int8>)
  • 这个方法只能获取到 用 property修饰过的属性。如:
    • @protocol NSString *string

二、class_copyIvarList

 class_copyIvarList(cls: AnyClass?,outCount: UnsafeMutablePointer<UInt32>?)
  • 获取所有属性:不管是 成员变量 还是 使用 property 修饰过的,都可以获取到

三、 class_copyMethodList

class_copyMethodList(cls: AnyClass?, outCount: UnsafeMutablePointer<UInt32>?)
  • 拷贝所有的方法

四、class_copyPropertyList

class_copyPropertyList(cls: AnyClass?, outCount: UnsafeMutablePointer<UInt32>?)
  • 拷贝所有的 property 属性

五、class_copyProtocolList

 class_copyProtocolList(cls: AnyClass?, outCount: UnsafeMutablePointer<UInt32>?)
  • 拷贝所有的协议

猜你喜欢

转载自blog.csdn.net/M316625387/article/details/82965411
今日推荐