0

我不确定我是否完全理解 RestKit。如何在保持其他关系的同时与自己建立关系?

我的 JSON 结构如下:

{
    "review" : {
        "id" : "123",
        "someotherkey" : "blah",
        "responses" : [
            {
                "id" : "345",
                "text" : "no"
            },
            {
                "id" : "346",
                "text" : "no"
            }
        ],
        "childReviews" : [
            {
                "id" : "124",
                "someotherkey" : "blsdah",
                "responses" : [
                    {
                        "id" : "347",
                        "text" : "no"
                    },
                    {
                        "id" : "348",
                        "text" : "no"
                    }
                ]
            },
            {
                "id" : "125",
                "someotherkey" : "blasdh",
                "responses" : [
                    {
                        "id" : "355",
                        "text" : "no"
                    },
                    {
                        "id" : "326",
                        "text" : "no"
                    }
                ]
            }
        ]
    }
}

所以对于我的 RestKit 我正在映射我有这样的东西:

 [reviewMapping addRelationshipMappingWithSourceKeyPath:@"childReviews" mapping:reviewMapping];
 [reviewMapping addRelationshipMappingWithSourceKeyPath:@"responses" mapping:responsesMapping];

当 childReview 对象不包含关键“响应”时效果很好,但现在我已经添加了它,它会破坏并给我这个错误:

*** Terminating app due to uncaught exception 'NSUnknownKeyException',
 reason:'[<Review 0x104f1260> valueForUndefinedKey:]: the entity
 Review is not key value coding-compliant for the key "responses".'

我不确定我是否完全理解 RestKit。如何在保持其他关系的同时与自己建立关系?

4

0 回答 0