我在将此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 Entity ...
@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实体做错了什么......?
提前致谢