In Swift you can easily get a string representation of an enumeration's case name, like so...
enum Foo
{
case laa1
case laa2
case laa3
}
let varHoldingTheStringLaa1 = String(Foo.laa1)
However, I can't figure out how to do the same for a class member, like so...
class Foo
{
var laa1:String = ""
var laa2:String = ""
var laa3:String = ""
}
// None of these work...
let varHoldingTheStringLaa1 = String(laa1) // Returns the value stored in laa1
let varHoldingTheStringLaa1 = String(Foo.laa1) // Won't even compile
So how can one get the member name stored in a variable?
Aucun commentaire:
Enregistrer un commentaire