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 7843661
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T16:37:12+00:00 2026-06-02T16:37:12+00:00

Say, I have my coredata structured to something like this… Class classID <- RestKit

  • 0

Say, I have my coredata structured to something like this…


Class

  • classID <- RestKit primaryKeyAttribute
  • name
  • time
  • students (relationship 1-to-many)

Student (nested in Class)

  • studentID
  • name
  • class (inverse relationship) <- RestKit primaryKeyAttribute ** this doesn’t work?! **

I specifed primaryKeyAttribute of the mappings as shown above. When I send a load request using restkit, it will correctly update object with the same primarykey. RestKit seems to update the class correctly, but for students, it just adds new ones and nullify the class relationship of old students. So now I have unwanted student entities in db with no reference to class.

Is there a way I can use RestKit to update the students relationship correctly? Btw, I thought about using studentID as primaryKeyAttribute instead, but it may not work correctly if have some students removed in the new updates. May be I have to clear all students for the class before updating, but I also don’t know how to do that in RestKit. Because by the time RKObjectLoader didLoadObject is called, seems like everything is already saved to the managedObjectContext. Any ideas? 🙁

  • 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-02T16:37:13+00:00Added an answer on June 2, 2026 at 4:37 pm

    Still can’t find a RestKit-way solution, and doesn’t look like there will be anyone who can answer this :-\ So I’m posting the best approach I can come up with.

    My current work around is to iterate through class’ students and manually delete them in objectLoader:willMapData:. I have to do here (not in objectLoader:didLoadObject:) because it is the place where the new data is not saved into MOC yet.

    You can also delete the Class entity entirely, but that way doesn’t actually updates the old one. It creates a new one with a new “core data internal _pk” (primary key) (yes, I do care about it).

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

Sidebar

Related Questions

Lets say I have a core data model like this one: Item attributes: name
Lets say have this immutable record type: public class Record { public Record(int x,
Let's say have something like: SELECT energy_produced, energy_consumed, timestamp1 AS timestamp FROM ( SELECT
Say I have this method public void test(IList<AvaliableFeaturesVm> vm) { } I have this
Say I have the following generic class: public class Foo<T extends Bar> { //
Say I have a method that returns this. Vector[ (PkgLine, Tree) ]() I want
Say I have a table name auto_parts with these fields. id, part, price, timestamp
Say i have this old manuscript ..What am trying to do is making the
For the sake of this example, let's say I have a button that every
When I have a CoreData entity named, say, 'Book', which has a one-to-one relationship

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.