找不到keyPath的对象映射

时间:2011-10-10 15:37:11

标签: objective-c ios cocoa restkit

我无法将JSON映射到我的实体。 错误信息是: 添加映射错误:无法找到keyPath的对象映射: ''。 我使用以下代码:

RKObjectMapping *lEgmMapping = [RKObjectMapping mappingForClass:[EGM 
class]]; 
    [lEgmMapping mapKeyPath:@"Id" toAttribute:@"Id"]; 
    [lEgmMapping mapKeyPath:@"InternalId" toAttribute:@"internalId"]; 
    [lEgmMapping mapKeyPath:@"PlayerType" toAttribute:@"playerType"]; 
    [lEgmMapping mapKeyPath:@"PositionX" toAttribute:@"x"]; 
    [lEgmMapping mapKeyPath:@"PositionY" toAttribute:@"y"]; 
    [lEgmMapping mapKeyPath:@"Size" toAttribute:@"size"]; 
    [lEgmMapping mapKeyPath:@"Status" toAttribute:@"status"]; 
    [[RKObjectManager sharedManager].mappingProvider 

    setMapping:lEgmMapping forKeyPath:@"GetEgmMarkersBySiteResult"]; 

我从网络服务获得以下JSON:

{"GetEgmMarkersBySiteResult":[{"Id": 
94,"InternalId":"A2345","PlayerType":"2","PositionX":686,"PositionY": 
1460,"Size":23,"Status":"0"},{"Id": 
83,"InternalId":"A1002a","PlayerType":"0","PositionX":1414,"PositionY": 
906,"Size":30,"Status":"0"},{"Id": 
81,"InternalId":"asd","PlayerType":"0","PositionX":1338,"PositionY": 
925,"Size":33,"Status":"0"}]} 

我做错了什么? 谢谢。

编辑: 事实证明,当它在appdelegate applicationlaunchedwithoptions上时,无法找到映射,我认为这是一个加载绑定的好地方。你认为哪里是加载绑定的好地方?如果另一个viewcontroller定义了相同的绑定,它会导致运行时错误吗?

0 个答案:

没有答案