title: How should I be associating Core Data entities for use with RestKit?
body: <p>I have two Core Data entities (<code>Client</code> and <code>UserFile</code>) that I have successfully set up a relationship between.</p>
  
  <p>I have created classes for both entities, and made them subclasses of <code>RKManagedObject</code>.</p>
  
  <p>When I create a new <code>UserFile</code>, I want to correctly associate it with a <code>Client</code>. Here's what I'm doing:</p>
  
  <pre><code>Client *client = [Client objectWithPrimaryKeyValue:@"1"];
  UserFile *file = [UserFile object];
  file.client = client;
  file.clientId = client.clientId;
  [[RKObjectManager sharedManager] postObject:file delegate:self];
  </code></pre>
  
  <p>It seems like I have to assign <code>file.clientId</code> so that the correct parameter is sent to the server (if I only assign <code>file.client</code> then the submitted <code>client_id</code> is blank).</p>
  
  <p>It seems like I have to assign <code>file.client</code> to prevent a new, empty <code>Client</code> from being created and associated with the file (the client relationship is required).</p>
  
  <p>Is this correct? Do I really have to assign both the foreign key and the actual entity? This seems a bit redundant to me, but I'll happily admit that my Core Data and RestKit knowledge is lacking!</p>