我有RestKit
这个问题,我无法弄明白。我正在尝试使用null
结果映射对象,但RestKit
由于某种原因无法处理该对象。我知道我做错了什么,但我无法弄清楚是什么。
这是我从服务中获得的回复:
{"responseError":null}
这是ResponseError.h文件:
@interface ResponseError : NSObject
@property (nonatomic,assign) NSInteger applicationErrorCode;
@property (nonatomic,strong) NSString *developerMessage;
@property (nonatomic,strong) NSString *userMessage;
@end
这是ResponseWithError.h文件:
@interface ResponseWithError : NSObject
@property (nonatomic,strong) ResponseError *responseError;
@end
这是对象的映射:
RKObjectMapping *responseErrorMapping = [RKObjectMapping mappingForClass:[ResponseError class]];
[responseErrorMapping addAttributeMappingsFromDictionary:@{ @"applicationErrorCode" : @"applicationErrorCode", @"developerMessage" : @"developerMessage",@"userMessage" : @"userMessage"}];
RKRelationshipMapping *responseErrorRelationMapping = [RKRelationshipMapping relationshipMappingFromKeyPath:@"responseError" toKeyPath:@"responseError" withMapping:responseErrorMapping];
RKObjectMapping *checkR = [RKObjectMapping mappingForClass:[ResponseWithError class]];
[checkR addPropertyMapping:[responseErrorRelationMapping copy]];
[[RKObjectManager sharedManager] addResponseDescriptor:[RKResponseDescriptor responseDescriptorWithMapping:checkR
method:RKRequestMethodPOST pathPattern:[RequestStringBuilder approveStatementChecks] keyPath: nil
statusCodes: RKStatusCodeIndexSetForClass(RKStatusCodeClassSuccessful)]];
这是我从RestKit获得的错误:
"No mappable object representations were found at the key paths searched."
提前致谢。