问题
Very similar question to Best way to implement Enums with Core Data
What is the best way to bind Core Data entities to enum values so that I am able to assign a type property to the entity? In other words, I have an entity called Item with an itemType property that I want to be bound to an enum, what is the best way of going about this in Swift?
回答1:
So far, this is my best approach. I still use the ObjC enum definition, as suggested in Daniel Eggert's answer to the same ObjC question as the Swift Enum doesn't seem to be backward compatible to ObjC. Hence, I added it to my bridge header.
来源:https://stackoverflow.com/questions/27656219/best-way-to-implement-enums-with-core-data-in-swift