1

我在将此 JSON 消息映射到相应的 core.data 实体时遇到了一些问题......

JSON:

{
"d": [
    "Copenhagen (CPH), Denmark",
    "Copenhagen, Roskilde (RKE), Denmark",
    "Comitan (CJT), Mexico",
    "Cooperstown (COP), New York, United States",
    "Copan (RUY), Honduras",
    "Copiapo (CPO), Chile",
    "Copper Center (CZC), Alaska, United States"
]
}

Core.Data 实体...

@interface MMAirportSimpleResult : NSManagedObject
@property (nonatomic, retain) NSString * name;
@end

@implementation MMAirportSimpleResult
@dynamic name;
@end

RestKit 是这样配置的...

RKEntityMapping *airportSimpleResultMapping =
[RKEntityMapping mappingForEntityForName:NSStringFromClass([MMAirportSimpleResult class]) inManagedObjectStore:[RKManagedObjectStore defaultStore]];

[airportSimpleResultMapping addPropertyMapping:[RKAttributeMapping attributeMappingFromKeyPath:nil toKeyPath:@"name"]];

RKResponseDescriptor *airportSimpleResultDescriptor = 
[RKResponseDescriptor responseDescriptorWithMapping:airportSimpleResultMapping pathPattern:@"services.asmx/CompleteAirportsSimple" keyPath:@"d" statusCodes:RKStatusCodeIndexSetForClass(RKStatusCodeClassSuccessful)];

[[RKObjectManager sharedManager] addResponseDescriptor:airportSimpleResultDescriptor];

这是我从 RestKit 得到的错误:

'NSInternalInconsistencyException', reason: 'Expected a dictionary representation' ...

我尝试使用简单的 NSObject 类进行映射,并且与上述配置完美配合......
我在 core.data 实体上做错了什么......?

提前致谢

4

0 回答 0