Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6112033
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T14:41:56+00:00 2026-05-23T14:41:56+00:00

I have two Core Data entities ( Client and UserFile ) that I have

  • 0

I have two Core Data entities (Client and UserFile) that I have successfully set up a relationship between.

I have created classes for both entities, and made them subclasses of RKManagedObject.

When I create a new UserFile, I want to correctly associate it with a Client. Here’s what I’m doing:

Client *client = [Client objectWithPrimaryKeyValue:@"1"];
UserFile *file = [UserFile object];
file.client = client;
file.clientId = client.clientId;
[[RKObjectManager sharedManager] postObject:file delegate:self];

It seems like I have to assign file.clientId so that the correct parameter is sent to the server (if I only assign file.client then the submitted client_id is blank).

It seems like I have to assign file.client to prevent a new, empty Client from being created and associated with the file (the client relationship is required).

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!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T14:41:56+00:00Added an answer on May 23, 2026 at 2:41 pm

    To answer your question, it looks like you do need to to both steps at the moment. Here’s the code from the RKDiscussionBoardExample included with the library:

    DBTopic* topic = [[DBTopic findFirstByAttribute:@"topicID" withValue:topicID] retain];
    _post = [[DBPost object] retain];
    _post.topicID = topic.topicID;
    _post.topic = topic;
    

    So either the relationships aren’t set up properly in the example, or you really do need both steps.

    Also, you should be using the newest version of RestKit which has a different object mapper and deprecates RKManagedObject. Your relationships should look something like this:

    RKManagedObjectMapping* clientMapping = [RKManagedObjectMapping mappingForClass: [Client class]];
    clientMapping.primaryKeyAttribute = @"clientID";
    [clientMapping mapKeyPathsToAttributes:
    @"id", @"clientID",
    nil];
    
    RKManagedObjectMapping* userFileMapping = [RKManagedObjectMapping mappingForClass:[UserFile class]];
    userFileMapping.primaryKeyAttribute = @"userFileID";
    [userFileMapping mapKeyPathsToAttributes:
     @"id", @"userFileID",
     @"client_id", @"clientID",
     nil];
    
    [userFileMapping mapRelationship:@"client" withObjectMapping:clientMapping];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using core data in my app. I have two entities that are related:
I have a core data model that has two entities, Bid and Result. I
In my Core Data model I have two entities: List and Patient. List has
I've got a window set up with two NSTableViews. In Core Data I have
Consider that i have two entities with following relationship: Entity A <-->> Entity B
I have two core data entities. Lets call them AAA and BBB . BBB
In my project, I have two Core Data entities. One is the grouping (can
I've created two entities in core data model (Courier and Occupation in this example),
I have two entities in a Core Data Model like these: A <<--->> B
I have a problem with Core Data which has left me at the end

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.