我是使用RESTKit的新手。
我正在尝试使用postObject
进行简单的POST。
我想知道我是否正确地这样做了。
我有这段代码:
self.gameWebInteractionObject = [[GameWebInteraction alloc] init];
RKObjectMapping *mapping = [RKObjectMapping mappingForClass:[NSMutableDictionary class]];
[mapping mapAttributes:@"id", @"firstname", @"lastname", @"email", @"createdGames", nil];
[self.gameWebInteractionObject.manager.mappingProvider setMapping:mapping forKeyPath:@""];
self.gameWebInteractionObject.manager.serializationMIMEType = RKMIMETypeJSON;
[self.gameWebInteractionObject.manager.router routeClass:[UserObject class] toResourcePath:@"/data" forMethod:RKRequestMethodPOST];
[self.gameWebInteractionObject.manager.mappingProvider setSerializationMapping:[mapping inverseMapping] forClass:[UserObject class]];
[self.gameWebInteractionObject.manager postObject:userobject delegate:self];
答案 0 :(得分:2)
如果您使用RestKit 0.20
// POST to create
[manager postObject:article path:@"/data" parameters:nil success:nil failure:nil];
// PATCH to update
[manager patchObject:article path:@"/data/1" parameters:nil success:nil failure:nil];
// DELETE to destroy
[manager deleteObject:article path:@"/data/1" parameters:nil success:nil failure:nil];
1是我的身份证。