Restkit创建NULL核心数据对象

时间:2012-05-09 01:38:41

标签: restkit

我正在使用Restkit构建应用程序以与Web服务同步。第一个loadObjectsAtResourcePath调用正常工作,但随后每个附加调用都会创建一个新的所有NULL行。典型的JSON响应是:

[{"item":{"created_at":"2012-04-19T19:42:44Z","id":4,"json_event_id":null,"name":"Biz Cards","theme_id":null,"updated_at":"2012-04-19T19:42:44Z","url":"","user_id":3}},{"item":{"created_at":"2012-04-20T19:37:33Z","id":5,"json_event_id":null,"name":"Hummus","theme_id":null,"updated_at":"2012-04-20T19:37:33Z","url":"","user_id":3}}]

第一次调用loadObjectsAtResourcePath时,我正确地获取了在核心数据中创建的两个对象。下次我调用它时,我在Sqlite中获得了一个带有新PK和所有NULL的额外行。每次后续调用都会创建一个新的NULL行,并且PK会增加。

这是我的映射:

RKManagedObjectMapping *itemsMapping = [RKManagedObjectMapping mappingForClass:[Items class] inManagedObjectStore:objectManager.objectStore];
itemsMapping.primaryKeyAttribute = @"itemID";
[itemsMapping mapKeyPathsToAttributes:@"created_at", @"createdAt",
 @"id", @"itemID",
 @"json_event_id", @"json_event_id",
 @"name", @"name",
 @"theme_id", @"theme_id",
 @"updated_at", @"updatedAt",
 @"url", @"url",
 @"user_id", @"user_id", nil];

这是我对网络服务的呼吁:

RKObjectManager *objectManager = [RKObjectManager sharedManager];
[objectManager loadObjectsAtResourcePath:@"/items" delegate:self];

有关为什么要创建这些额外行的任何帮助都将非常感谢!

0 个答案:

没有答案