Magical Record import with already existing data

I’m trying to use Magical Record to import data into my CoreData db.

I’m working on the entity Person at the moment.

  • Remove nested key from dictionary
  • How to prevent load of meteor.local (when building ios app with phonegap)
  • Returning object from callback in Swift
  • RxSwift: Two way binding
  • iOS CoreLocation: Is it possible to know if the location data is coming from GPS or from Wifi?
  • Check if view controller is presented modally, or pushed on a navigation stack
  • A Person has firstName, lastName, personID attributes. (I know I don’t need the idString, I’m not using it internally, it is used to talk back to the server).

    Anyway, if I already have the person…

    firstName - John
    lastName - Smith
    personID - 1

    And I download the JSON…

            firstName: John,
            lastName: Doe,
            id: 1
            firstName: Michael,
            lastName: Caine,
            id: 2
            firstName: Angelina,
            lastName: Jolie,
            id: 3

    I’d want the import to add Michael and Angelina and to update John Smith to John Doe because it already exists with the same id vs personID.

    I’ve set the mappedKeyName between id and personID.

    Is it possible to do this? I’ve been reading this blog… about automatic mapping of key names etc… and wondered if I could exploit this to do what I want?

    I have read the part about relatedByAttribute from the blog but I’m not sure where I should be setting it and what to?

    Should I set it on the entity Person? Or the attribute personID? And what should I set it to? “id”? Or something else?

    Solutions Collect From Internet About “Magical Record import with already existing data”

    I’m not sure if you’re using the relatedByAttribute setting in the userInfo area of your Core Data model. You don’t mention that in your issue here. I suggest you double check that. And to clarify, it’s called relatedByAttribute because the string you put into the value section is the CoreData attribute which relates the entities, no the json (or other object) data. So, check those two things and if there still a problem, please open a ticket on github, preferably with a unit test that helps describe the problem.