클래스의 내부정보를 분석하는 것으로 java에서 제공하듯 swift에서도 제공된다.
let mirror = Mirror(reflecting: object);
for child in mirror.children {
if let value = child.value as? String {
}
}
mirror.children의 child값의 collection이고 child는 label과 value 값을 갖는다.
https://www.swiftbysundell.com/articles/reflection-in-swift/
https://developer.apple.com/documentation/swift/mirror/children
댓글 없음:
댓글 쓰기