Restkit 0.20 JSON映射以及其他离线数据

所以我们假设我有一个像这样的JSON对象:

{ "userList" : [ { "ID" : 1, "firstName" : "John", "lastName" : "Doe" }, { "ID" : 2, "firstName" : "Jane", "lastName" : "Doe" } ] } 

我可以将这个对象映射到具有以下属性的user类中:

 ID, firstName, lastName, createdDate, modifiedData 

问题出现在我需要更新modified date我希望能够插入一个数据时间标记,每当我做一个映射,当我在离线模式下修改数据时。

所以我的问题是,如何将JSON对象映射到核心数据,同时插入一些不存在于JSON对象中的数据。 这甚至有可能吗?

================

我的映射function,如果有帮助:

 + (RKObjectMapping *)mapping { // Create a singleton instance of the mapping object. __strong static RKEntityMapping *_mapping = nil; static dispatch_once_t onceToken; dispatch_once(&onceToken, ^{ RKManagedObjectStore *store = [[RKObjectManager sharedManager] managedObjectStore]; _mapping = [RKEntityMapping mappingForEntityForName:NSStringFromClass([self class]) inManagedObjectStore:store]; // Map attributes with the same name in the JSON and the model. [_mapping addAttributeMappingsFromDictionary:@{@"ID": @"ID", @"firstName" : @"firstName", @"lastName" : @"lastName"}]; // Set primaryKeyAttribute _mapping.identificationAttributes = @[@"ID"]; }); return _mapping; } 

在RestKit之外处理这个,但是以RestKit(和其他任何改变)触发的方式处理:

覆盖将willSave在您的托pipe对象的子类上,并在调用时更新修改的date(设置原始值以避免recursion)。