Untitled
unknown
plain_text
a year ago
376 B
20
Indexable
import Foundation
class MyClass {
private var privateProperty: String = "Secret"
var publicProperty: String = "Visible"
}
let myObject = MyClass()
let mirror = Mirror(reflecting: myObject)
// Reflect over the object's properties
for child in mirror.children {
if let label = child.label {
print("Property name: \(label), value: \(child.value)")
}
}
Editor is loading...
Leave a Comment