How to save and read enum values in NSDictionary in Swift.
I have identified several types
enum ActionType {
case Person
case Place
case Activity
}
Write enumeration to dictionary
myDictionary.addObject(["type":ActionType.Place])
"AnyObject does not have a name with a name"
Read
var type:ActionType = myDictionary.objectForKey("type") as ActionType
"Type" ActionType "does not conform to the protocol" AnyObject ""
I also tried to wrap ActionType as NSNumber / Int, which didn’t quite work. Any tips on properly storing and reading enum values in NSDictionaries?
Bernd source
share