与restkit具有相同对象的子对象的JSON对象enityt

时间:2013-01-03 18:19:07

标签: ios restkit

我不确定我是否完全了解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。如何在保持其他关系的同时与自己建立关系?

0 个答案:

没有答案