Reputation: 3628
I'm in the process of learning how to work with Core Data.
foo
objects are a collection of bar
objects that share similar properties. foo
has some of its own members, one of which is an array of bar
objects.
In order to manage the foo
s with Core Data, do I need to model only the foo
s? Do they both need to be subclasses of NSManagedObject
? I do not need undo functionality on either.
Upvotes: 1
Views: 87
Reputation: 776
CoreData is just like working with Relational Model in Databases.
Define One table/entity/object(in objective-c, defined in tabular form), and use to related it with another using foreign key mechanism, or for more complex problems use third entity(called relation) i.e also a table.
Table 1: for foo's
fooID
barID
barID
.
.
barID
fooAttrib1
.
.
fooAttribn
barArrayAttribID
Table 2: for bar's
barID
barAttrib1
.
.
barAttribn
Table 3: for foo's Attribute/member(that is an array pf bar's)
barArrayAttribID
barID
in table 3 barArrayAttribID is mapped from table 1, and linked with as many barID, in table 2, as the array have.
Upvotes: 0
Reputation: 8918
I envision your object graph as follows:
Foo entity
Bar entity
All entities are NSManagedObjects (or a subclass).
Upvotes: 1