-->

Inherit from SPManagedObject

2019-02-19 11:31发布

问题:

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.



标签: simperium