Last active
February 22, 2019 09:18
-
-
Save andr3a88/b55ca432639568330f987fc90f9ca9b5 to your computer and use it in GitHub Desktop.
Reflection in Swift [Playground]
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import UIKit | |
class UserSession { | |
let name: String = "Mario" | |
let id: String = "id_123123123" | |
let token: String = "s79s2waas9432j2jf23f2" | |
} | |
let userSession = UserSession() | |
/// Mirror currently doesn’t support writing any values, only reading them | |
let mirror = Mirror(reflecting: userSession) | |
for child in mirror.children { | |
print("Property name:", child.label ?? "") | |
print("Property value:", child.value) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment