HiveHicks
HiveHicks

Reputation: 2334

RestKit: add relationship connection to the certain NSManagedObject when mapping another NSManagedObject

I've got two entities: Order and OrderInfo, both of them are NSManagedObject subclasses. OrderInfo has got a relationship order.

Now, I've already got a certain Order instance in my managed object context (let's call it myOrder), and I want to load OrderInfo that corresponds to myOrder from server.

How should I instruct RestKit to fill order relationship property of OrderInfo with myOrder during mapping?

Upvotes: 0

Views: 370

Answers (1)

Wain
Wain

Reputation: 119031

You need to use a technique called foreign key mapping. You need to have unique identifiers on each of the objects (well, at least the existing one you need to find in the data store) and then you tell RestKit about the relationship to populate, the identity key of the target and the identity key of the value in your received data to match against.

Upvotes: 1

Related Questions