Best way to implement Enums with Core Data in Swift

孤街浪徒 提交于 2020-01-05 05:24:30

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!