Restkit:映射操作没有找到任何可映射的内容

时间:2012-08-27 15:58:28

标签: ios object mapping restkit

我是RestKit的新手,在设置我的第一个对象映射时遇到问题...日志语句说“ 映射操作没有找到任何可映射的内容“

这是我的代码:

- (void)setupConnector

{

    [RKClient clientWithBaseURL:[NSURL URLWithString:WS_URL]];

    RKLogConfigureByName("RestKit", RKLogLevelDebug);

    RKLogConfigureByName("RestKit/ObjectMapping", RKLogLevelDebug);

    RKLogConfigureByName("RestKit/Network", RKLogLevelDebug);



    RKObjectManager* manager = [RKObjectManager objectManagerWithBaseURL:[NSURL URLWithString:WS_URL]];

    manager.objectStore = [RKManagedObjectStore objectStoreWithStoreFilename:@"db.sqlLite"];

}



- (void)setupMapping

{

    RKObjectManager *manager = [RKObjectManager sharedManager];

    RKManagedObjectMapping *storyMapping = [RKManagedObjectMapping mappingForEntityWithName:@"Story" inManagedObjectStore:manager.objectStore];



    [storyMapping mapKeyPath:@"id" toAttribute:@"storyID"];

    [storyMapping mapKeyPath:@"title" toAttribute:@"title"];

    storyMapping.primaryKeyAttribute = @"storyID";

    storyMapping.setDefaultValueForMissingAttributes = YES;

    [manager.mappingProvider setMapping:storyMapping forKeyPath:@""];

    [manager.mappingProvider addObjectMapping:storyMapping];

    [[RKObjectManager sharedManager] loadObjectsAtResourcePath:@"/Story/1?format=json" usingBlock:^(RKObjectLoader* loader) {

    [loader setObjectMapping:storyMapping];

    }];

}

以下是日志声明:

2012-08-19 14:25:39.108[68878:4903] D restkit.object_mapping:RKObjectMapper.m:222 Asked to map source object {

result =     {

    creatorName = admin;

    dateCreated = "/Date(1343603174000-0700)/";

    dateModified = "/Date(1343603180000-0700)/";

    genre = Fantasy;

    gradeVoteCount = 0;

    id = 1;

    isFinished = 0;

    isLocked = 0;

    isPublic = 0;

    storyCountTotal = 0;

    title = "First STory";

};

} with mapping <RKManagedObjectMapping:0x7673230 objectClass=Story keyPath mappings => (

"RKObjectKeyPathMapping: id => storyID",

"RKObjectKeyPathMapping: title => title"

)>

2012-08-19 14:25:39.109[68878:4903] D     restkit.object_mapping:RKObjectMappingOperation.m:655 Starting mapping operation...

2012-08-19 14:25:39.109[68878:4903] D restkit.object_mapping:RKObjectMappingOperation.m:676 Mapping operation did not find any mappable content

2012-08-19 14:25:39.109[68878:4903] D restkit.object_mapping:RKObjectMapper.m:367 The following operations are in the queue: (

)

2012-08-19 14:25:39.110[68878:4903] D restkit.object_mapping:RKObjectMapper.m:382 Finished performing object mapping. Results: {

如果有人能让我开始走上正确的道路,我将非常感激。)

非常感谢!

0 个答案:

没有答案