0

I am using Restkit to seed a database using a Json file. My problem is with how to construct the file to represent the relationships between the objects when the same object is referenced by two other objects.

In my application I have a set of Locations, each of which can have 1 or more People, however I also have a set of Groups, each of which can also have 1 or more People. The names don't matter. What matters is that some People exist both in a Group and in a Location. How can I represent these relationships using a Json file and correctly map these relationships to objects using Restkit?

Undistraction
  • 42,754
  • 56
  • 195
  • 331

1 Answers1

1

I think I can help, but I'll need to see your JSON. You can set relationships like this:

[MyMapping mapKeyPath:@"KeyPath" toRelationship:@"Relationship" withMapping:MyMapping];
iDev
  • 35
  • 7
  • You sure you should be using MyMapping twice in there? Seems like `[locationMapping mapKeyPath:@"people" toRelationship:@"people" withMapping:personMapping];` might be a better example. – drewish Jul 19 '12 at 14:23
  • You can use MyMapping twice if you're mapping your objects recursively. But you are correct in that your example is better for the average relationship mapping. – iDev Aug 01 '12 at 22:03