使用restkit在coredata中的空值

时间:2012-10-03 14:50:08

标签: iphone ios5 restkit

我正在使用restkit处理核心数据,我有两个模型(帖子和照片)现在一个帖子有很多照片,我在模型中映射的帖子中有照片,coredata中的条目已完成,但是照片的值为null,

在帖子中有5张照片,这些记录插入到coredata中,但值为空

这里是映射代码

照片制图

- (RKManagedObjectMapping *)photosMapping {
   RKManagedObjectMapping *mappingPhoto = [RKManagedObjectMapping mappingForClass:[DBPhoto class] inManagedObjectStore:self.objectStore];
   mappingPhoto.setDefault``ValueForMissingAttributes = NO;
   mappingPhoto.primaryKeyAttribute = @"photoID";
   [mappingPhoto mapKeyPathsToAttributes:
    @"id", @"photoID",
    @"full_url", @"full_url",
    @"thumb_url", @"thumb_url",
    nil];
   return mappingPhoto;``
}


-
},


Post Mapping 

[mappingPost mapKeyPath:@"photos" toRelationship:@"photos" withMapping:[self photosMapping]];

The Json response for Post is 

"post": {
"id": 4,
"topic": "Post Meniscectomy Knee Pain",
"body": "<p>I&#39;ve got a healthy, active 60 yo woman with normal to low BMI who is s/p partial medial meniscectomy x 2 in the past 7 years (last was two years ago).&nbsp; She has relatively benign articular cartilage throughout the knee, including medially.</p><p>&nbsp;Her <u>medial joint line tenderness and pain</u> and really bothering her and she has a small Baker&#39;s cyst.&nbsp; Her MRI 1/2008 shows, not surprisingly, an irregular medial meniscus, possible tear/globular, small B cyst.</p><p>Her alignment is a couple degrees of physiologic varus bilaterally, nothing too impressive.</p><p>standing AP, 45 PA Xrays are more or less normal, other than symmetrical, slight narrowing in the medial compartment bilaterally.</p><p>She wants to get back to her daily walk and some limited cardio exercise activities.&nbsp; </p><p>I tried an unloader brace a year ago, and she was not very compliant with it. What options would you consider?&nbsp; She&#39;s obviously &#39;old&#39; for a meniscal allograft, and I don&#39;t know if her personality would tolerate it, but her cartilage was benign when I scoped her two years ago</p>",
"comments_count": 26,
"votes_count": 8,
"views_count": 1,
"created_at": "2008-06-03T04:40:00-03:00",
"updated_at": "2012-04-01T04:08:08-03:00",
"has_poll": true,
"has_photos": true,
"has_videos": true,
"has_documents": false,
"subspecialty": {
"id": 5
},-
"user": {
"id": 15
},-
"post_type": {
"id": 1
},-
"forum_type": {
"id": 1
},-
"tags": [(5)
{
"tag": {
"id": 50
}-
},-
{
"tag": {
"id": 51
}-
},-
{
"tag": {
"id": 52
}-
},-
{
"tag": {
"id": 53
}-
},-
{
"tag": {
"id": 54
}-
}-
],-
"": [(0)],
"poll": {
"id": 2,
"title": "Primary Treatment Options?",
"a1": "Medial Unloader Brace and live with it",
"a2": "Scope it, Meniscectomy then Unloader brace",
"a3": "Medial Unicompartmental Arthroplasty",
"a4": "Medial Meniscal Allograft",
"a5": "Total Knee Replacement"
},-
"photos": [(1)
{
"photo": {
"id": 2,
"full_url": "/uploads/photos/posts/4/2_9371a426ef.jpg",
"thumb_url": "/uploads/photos/posts/4/2_9371a426ef_thumb.jpg"
}-
}-
],-
"videos": [(1)
{
"video": {
"id": 133,
"full_url": "/images/fallback/videos/default.gif",
"thumb_url": "/images/fallback/videos/thumb_default.gif"
}-
}-
]-
}-
}

强调文字

这是我访问照片模型时的响应

"<DBPhoto: 0x7daf4d0> (entity: DBPhoto; id: 0x7d9a5e0 <x-coredata://162D7572-B46F-4566-92E6-C07DA4ABEAD2/DBPhoto/p1> ; data: <fault>)",
   "<DBPhoto: 0x7dae460> (entity: DBPhoto; id: 0x7d9cfb0 <x-coredata://162D7572-B46F-4566-92E6-C07DA4ABEAD2/DBPhoto/p2> ; data: <fault>)",
   "<DBPhoto: 0x7da8ab0> (entity: DBPhoto; id: 0x7d9bd70 <x-coredata://162D7572-B46F-4566-92E6-C07DA4ABEAD2/DBPhoto/p3> ; data: <fault>)",
   "<DBPhoto: 0x7dad8f0> (entity: DBPhoto; id: 0x7da3040 <x-coredata://162D7572-B46F-4566-92E6-C07DA4ABEAD2/DBPhoto/p4> ; data: <fault>)",
   "<DBPhoto: 0x7daa240> (entity: DBPhoto; id: 0x7d92c10 <x-coredata://162D7572-B46F-4566-92E6-C07DA4ABEAD2/DBPhoto/p5> ; data: <fault>)"

但这些条目为空。他们在数据库中

0 个答案:

没有答案