设备上的RESTKIT 0.22 CoreData问题

时间:2014-06-03 08:46:30

标签: ios core-data restkit

我有一个奇怪的问题,restkit映射到CoreData。一切都在模拟器中很好用,但在真实设备中却不行。成功请求服务器后,两种情况下的结果映射都成功(我可以访问RKMappingResult * mappingResult中的每个值)。新值存储在模拟器中,但它们不存储在设备中。我做了很多谷歌搜索,但没有解决方案。

我这样做restkit:

RKObjectMapping *requestMapping =  [[hcUpdateRequest defineUpdateRequestMapping] inverseMapping];

[self.objectManager addRequestDescriptor: [RKRequestDescriptor requestDescriptorWithMapping:requestMapping objectClass:[hcUpdateRequest class] rootKeyPath:nil method:RKRequestMethodPOST]];

RKEntityMapping *storyMapping = [hcUpdateResponse storyMapping:self.objectManager.managedObjectStore];
{..moreMapping..}


[storyMapping addPropertyMapping:[RKRelationshipMapping relationshipMappingFromKeyPath:@"pieces" toKeyPath:@"pieces" withMapping:pieceMapping]];
{..moreMapping..}


[self.objectManager setRequestSerializationMIMEType: RKMIMETypeFormURLEncoded];

[self.objectManager postObject:self.dataUpdateRequst
                          path:@"storyAll"
                    parameters:nil
                       success:^(RKObjectRequestOperation *operation, RKMappingResult *mappingResult) {…}


+ (RKEntityMapping*) storyMapping:(RKManagedObjectStore*)managedObjectStore {

    RKEntityMapping* storyMapping = [RKEntityMapping mappingForEntityForName:@"Story" inManagedObjectStore:managedObjectStore];
    [storyMapping addAttributeMappingsFromDictionary:@{
                                                       @"id":@"idRemoteDatabase",
                                                       @"name":@"name",
                                                       @"position_x": @"positionX",
                                                       @"position_y": @"positionY",
                                                       @"state": @"state",
                                                       @"gender": @"gender"
                                                       }];
    storyMapping.identificationAttributes = @[@"idRemoteDatabase"];
    return storyMapping;

}

0 个答案:

没有答案