MagicalRecords import data from JSON / NSDictionary. Import relationships

前端 未结 2 527
感情败类
感情败类 2021-01-07 11:41

I have questions with relationships. I have to NSManagedObject classes Team and Player. Team can contain many players. Player can contain only one team.

Here is the

相关标签:
2条回答
  • 2021-01-07 12:00

    I solved this problem one thing I miss was mappedKeyName for the Relationship's user info.

    At first we need to set mappedKeyName for the relationship that corresponds to the JSON key.

    So in case if JSON you got looks like below:

    {
        "status": 1,
        "message": "success",
        "player": {
            "playerID": 1,
            "teamID": 14,
            "firstname": "NAME",
        }
    }
    

    mappedKeyName key will be player.teamID

    relatedByAttribute key will be teamID that is an attribute of the Team entity.

    Hope it helps someone.

    enter image description here

    0 讨论(0)
  • 2021-01-07 12:03

    Have a look at this answer I posted for another question similar to yours:

    Magical Record import (next step)

    0 讨论(0)
提交回复
热议问题