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

  • SEARCH
  • Home
  • 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 9163529
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T14:28:09+00:00 2026-06-17T14:28:09+00:00

I have a iOS Restkit related question. I have a parent-child relationship data coming

  • 0

I have a iOS Restkit related question. I have a parent-child relationship data coming from a remote server and map those object to a NSManagedObject object with Restkit. The problem that I am currently having is every request to the server always wipe out the “child” relationship and replace it with the new data coming from the server. Is there a way to avoid those and append the new child instead?

For example: I have a classic Category –> Products relationship.

{"categories": [
    {
        "cat_id": "1",
        "cat_title": "category 1",
        "cat_tag": 1,
        "product": [
            {
                "prod_id": "1",
                "prod_name": "product 1",
                "prod_tag": 1
            },
            {
                "prod_id": "2",
                "prod_name": "product 2",
                "prod_tag": 1
            }
        ]
    }
] }

And that works fine and everything is saved properly with the relationship on the CoreData. But if I make another request to the server and have a new response:

{"categories": [
    {
        "cat_id": "1",
        "cat_title": "category 1",
        "cat_tag": 1,
        "product": [
            {
                "prod_id": "3",
                "prod_name": "product 3",
                "prod_tag": 1
            },
            {
                "prod_id": "4",
                "prod_name": "product 4",
                "prod_tag": 1
            }
        ]
    }
] }

I will have product 3 and product 4 replace product 1 and product 2 on the database. I am sure I setup all the relationship and primary key correctly. (Both cat_id and prod_id are set as a primary key).

Having investigated through the RestKit’s internal framework, I noticed that around line 576 in the RKObjectMappingOperation class, there is

RKLogTrace(@"Mapped NSSet relationship object from keyPath '%@' to
           '%@'. Value: %@", relationshipMapping.sourceKeyPath,
           relationshipMapping.destinationKeyPath, destinationObject);

NSMutableSet *destinationSet = [self.destinationObject
                         mutableSetValueForKey:relationshipMapping.destinationKeyPath];
[destinationSet setSet:destinationObject];

So I guess that is easy to just change

[destinationSet setSet:destinationObject];

to

[destinationSet addObjectsFromArray:[destinationObject allObjects]]

But I was wondering whether there is a better way to do it?

Cheers,

  • 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-06-17T14:28:10+00:00Added an answer on June 17, 2026 at 2:28 pm

    Thanks for the support from Reskit. It is now supported by RKRelationshipMapping.(https://github.com/RestKit/RestKit/issues/989)

    Just set assignmentPolicy value of RKRelationshipMapping instance to RKUnionAssignmentPolicy

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

am just starting off with restkit for ios. I have a very simple json
i have ios application with xcdatamodeld, i want update some data so need a
I have the following method that makes a webservice call from my iOS app
I have an iOS app which I need to upload the binary of. From
I am new to ios/RESTKIT. I am trying to consume a webservice from an
I have an iOS app using RestKit in order to communicate with a RESTful
I have to access Rest api in iOS and i am using RestKit for
I'm using the RestKit iOS package to allow a user to pull info from
I have ios application with datetimepicker, and i am store the date in to
I have an iOS project to open and when i open it i get

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.