Reputation: 2053
I have two NSManagedObject subclasses, Person and Photo, that I am storing with CoreData. I need a comment object for a photo, and I was wondering if I should create a new NSManagedObject subclass and store it in core data, or create a subclass of nsobject and have an array of those in my Photo object? Which is the best thing to do? What are the pros and cons of each one?
Upvotes: 2
Views: 1162
Reputation: 8664
If you have an array in Photo... Photo is a NSMagangedObject, so it would end up being store in core data if you want to keep them around. And that array would probably need to be converted in an NSValue...
Core Data is like a data base on many aspect, and in a data base you don't think arrays, you think tables.
So I strongly suggest NSManagedObject.
It would potentially allow you to query for all photos that have comments add or modified in a specific day. That thing would be extremely complicated to achieve with the array model you are proposing.
Upvotes: 1
Reputation: 379
in my opinion, using Core Data is much better;
because you can use the relation to get the comment directly , and cache your comment in the database will release the time of request from the server~
Upvotes: 1