Inherit from SPManagedObject

雨燕双飞 提交于 2019-12-01 08:40:52

问题


In Simperiums iOS/OSX tutorial you say, each modeled object should inherit from SPManagedObject.

I didn't try it yet, but doesn't that lead to one big table in the SQLite database that contains a union of all fields of all modeled managed objects?


回答1:


Yes, under the hood Core Data will tend to create a bigger table. Generally performance will suffer more from relations though, not inheritance: Using Parent Entity in CoreData Models

We've done integrations with fairly complex inheritance hierarchies and didn't see any immediate issues with a fair amount of data.

Having said that, should you need more control over your table structure, you can avoid having a single parent for all your objects and instead either:

  1. Manually add the ghostData and simperiumKey attributes to the objects you want to sync, and ensure their class is SPManagedObject (or ensure their custom class inherits from SPManagedObject), or

  2. Create more than one parent entity with ghostData and simperiumKey attributes, and inherit from those for the parts of your model where it makes sense, depending on how you'd like the underlying tables to be structured.



来源:https://stackoverflow.com/questions/10565002/inherit-from-spmanagedobject

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