0

I have two objects I need to create a relationship between in Core Data. I am not sure how to setup the relationship. When I try I then run my app it loops forever and crashes (guessing circular reference).

mainObject.h

NSString *userId;
NSString *thing;
NSString *descr;
NSString *title;

authObject.h

NSString *userId;
BOOL     alive;
BOOL     authCode;

How do I setup this relationship in CD? mainObject can have multiple authObjects. How do I relate userId on both objects to each other in CD?

jrturton
  • 118,105
  • 32
  • 252
  • 268
jdog
  • 10,351
  • 29
  • 90
  • 165
  • 1
    What does your data model look like? Relationships are defined there, and the properties and ivars are generated automatically in your managed object subclass files. – jrturton Jun 11 '12 at 15:40
  • mainObject has-many authObjects (see above for their attributes). The relationship on mainObject side is "auths" and the relationship (inverse) on the authObjects is "main". – jdog Jun 11 '12 at 19:10
  • Something similar here, but I think I can figure it out from this post stackoverflow.com/questions/9318565/restkit-object-mapping-relationships-without-kvc/9318745#9318745 – jdog Jun 11 '12 at 19:52
  • It's not clear where your problem is. Core data relationships are just properties on an object - for example, you'd set the `main` property on your authObject to an instance of `mainObject` and boom - you're done. Can you include some of the code you are trying that is causing you difficulties? – jrturton Jun 11 '12 at 20:05
  • Answered: http://stackoverflow.com/questions/9318565/restkit-object-mapping-relationships-without‌​-kvc/9318745#9318745 – jdog Jun 11 '12 at 21:54
  • 1
    Please answer your question with the solution you found and set it as marked. Thank you. – Lorenzo B Jun 11 '12 at 22:04
  • I'm not sure how that does answer your question, since it is about Restkit, which you haven't mentioned, but you know best! – jrturton Jun 12 '12 at 05:44

1 Answers1

0

I am using restkit and my scenario is identical to this

As for the CoreData side, I figured it out by reading through that post and filling in the gaps. Mainly, I had it pretty much right, but that post confirmed my suspicions.

Not sure how to mark this as answered.

Community
  • 1
  • 1
jdog
  • 10,351
  • 29
  • 90
  • 165