Swift|Swift 之用 Swift 运行时获取对象属性列表

// //Animal.swift //demo // //Created by 八月夏木 on 2017/11/30. //Copyright ? 2017年 八月夏木. All rights reserved. //import UIKitclass Animal: NSObject {@objc var name: String?@objc var age: Int = 0@objc var species: String?init(dict: [String: Any]) {super.init()setValuesForKeys(dict) }class func propertyList() -> [String] { var count: UInt32 = 0let list = class_copyPropertyList(self, &count)print("属性个数:\(count)")// for i in 0..

    推荐阅读