我正在使用REST Kit 0.10.0,但无法执行RKRequestMethodPOST
.
我的数据库名称是dbo.Patients,表名称是Patient。
它包含 3 列,例如ID,Name,Address
这是我的代码,
[[RKClient sharedClient] get:@"/Patient" delegate:self];
RKObjectMapping *venueMapping = [RKObjectMapping mappingForClass:[Venue class]];
RKURL *baseURL = [RKURL URLWithBaseURLString:@"http://175.78.1.4/MyAppTestData/MyAppDataService.svc"];
RKObjectManager *objectManager = [RKObjectManager objectManagerWithBaseURL:baseURL];
objectManager.client.baseURL = baseURL;
[venueMapping mapKeyPathsToAttributes:@"ID",@"Id",@"Name",@"name",@"Address",@"midname",nil];
[objectManager.mappingProvider setMapping:venueMapping forKeyPath:@"value"];
RKObjectMapping* venueMappingS = [RKObjectMapping mappingForClass:[Venue class]];
venueMappingS.setDefaultValueForMissingAttributes = YES;
[[RKClient sharedClient] setUsername:@"sa"];
[[RKClient sharedClient] setPassword:@"123"];
RKObjectRouter *router = [[RKObjectRouter alloc] init];
[router routeClass:[Venue class] toResourcePath:@"/Patient" forMethod:RKRequestMethodPOST];
[[[RKObjectManager sharedManager] mappingProvider] setMapping:venueMappingS forKeyPath:@"value"];
[[RKObjectManager sharedManager].mappingProvider setSerializationMapping:[venueMappingS inverseMapping] forClass:[Venue class]];
[RKObjectManager sharedManager].router = router;
[RKObjectManager sharedManager].serializationMIMEType = RKMIMETypeJSON;
[RKObjectManager sharedManager].acceptMIMEType = RKMIMETypeJSON;
Venue* venue = [[Venue alloc] init];
venue.Id = 4;
venue.name = @"User1";
venue.midname = @"Chicago";
[[RKObjectManager sharedManager] postObject:venue delegate:self];
目前它显示错误为
W restkit.object_mapping:RKObjectMapper.m:81 添加映射错误:找不到 keyPath 的对象映射:''
这是我的场地课程
@interface Venue : NSObject
@property (strong, nonatomic) NSString *uri;
@property (strong, nonatomic) NSString *name;
@property (strong, nonatomic) NSString *midname;
@property (strong, nonatomic) NSString *lastname;
@property (strong, nonatomic) NSString *mrn;
@property (strong, nonatomic) NSString *gender;
@property (strong, nonatomic) NSString *accession;
@property (strong, nonatomic) NSDate *dob;
@property (nonatomic) int Id;
@end
对此的任何帮助表示赞赏。
谢谢。