samedi 28 février 2015

Name of enumeration value in Swift, does not return String. :( description)

someone already said that to print a name out of an enum you have to implement something like this:


enum itemlist: Int { case nothing = 0, healingpotion, manapotion



var description : String {
get {
switch(self) {
case .nothing:
return "---"
case .healingpotion:
return "Healingpotion"
case .manapotion:
return "Manapotion"
}
}
}


}


when i call this parameter it stil returns the number. what am i missing?


player.item1.description // result 1 and not healingpotion


Aucun commentaire:

Enregistrer un commentaire