Untitled

mail@pastecode.io avatar
unknown
plain_text
11 days ago
376 B
3
Indexable
Never
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)")
    }
}
Leave a Comment