Core Data relationships not mapped with RESTkit

前端 未结 1 1185
迷失自我
迷失自我 2021-02-11 02:35

I am struggling to get a proper mapping of Core Data relationships using RESTkit 0.20.0-pre6.

I want to map this JSON:

{ \"items\" : [ {\"id\" : 2001, \"         


        
1条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-02-11 02:59

    I got it working. The trick was to add an extra attribute 'roomId' on ItemMO for the foreign key.

    Entity ItemMO (Attributes "id", "roomId", "itemAttr1", Relationship "room" to RoomMO)
    

    Then tell RESTkit about the relation:

    [itemMapping addConnectionForRelationship:@"room" connectedBy:@{@"roomId" : @"id"}];
    

    It seems as if RESTkit cannot establish the relation without the extra foreign key attribute.

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