除了完成JSON和Model的转换之外,KakaJSON内部还有很多实用的功能,有些也开放为public接口了

遍历属性

struct Cat {
    var age: Int = 0
    let name: String = ""
}

guard let type = Metadata.type(Cat.self) as? ModelType,
    let properties = type.properties else { return }

for property in properties {
    print(property.name,
          property.type,
          property.isVar,
          property.ownerType,
          property.offset)
    // age Int true Cat 0
    // name String false Cat 8
}

相关文章:

  • 2021-09-16
  • 2021-04-20
  • 2021-06-02
  • 2021-12-26
  • 2021-05-25
  • 2021-08-08
  • 2021-06-04
猜你喜欢
  • 2022-01-03
  • 2021-06-27
  • 2021-08-11
  • 2022-01-01
  • 2022-12-23
  • 2021-04-19
  • 2021-08-13
相关资源
相似解决方案