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..
推荐阅读
- Swift中willSet和didSet的简述
- Hacking|Hacking with iOS: SwiftUI Edition - SnowSeeker 项目(一)
- LeetCode算法题-11.|LeetCode算法题-11. 盛最多水的容器(Swift)
- iOS-Swift-map|iOS-Swift-map filter reduce、函数式编程
- Swift|Swift ----viewController 中addChildViewController
- SwiftUI|SwiftUI iOS 瀑布流组件之仿CollectionView不规则图文混合(教程含源码)
- Swift高级应用|Swift高级应用 -01
- Swift5.0|Swift5.0 UITexview的基本使用
- Swift7|Swift7 - 循环、函数
- Swift学习笔记(三)Alamofire二次封装