class Wesley: Developer {
let name = "Wesley de Groot"
let age = 34
let location: Location = .Netherlands
let languages: [Languages] = [.Dutch, .English]
let programmingLanguages = ["Swift", "Objective-C", "JavaScript", "PHP"]
let markup = ["HTML", "CSS"]
func details() -> String {
var details = ""
for detail in Mirror(reflecting: self).children {
guard let label = detail.label else { continue }
details.append("\(label.capitalized): \(detail.value)\n")
}
return details
}
}
print(Wesley().details())
// The above doesn't compile?
// Just add this "missing" code.class Developer {
enum Location { case Netherlands }
enum Languages { case Dutch, English }
}
Exploring the .inspector Modifier in SwiftUI
Interested learning more about Swift? Check out my blog.