0

我是使用 RESTKit 的新手。

我正在尝试使用postObject.

我想知道我这样做是否正确。

我有这段代码:

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];
4

1 回答 1

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是我的身份证。

https://github.com/RestKit/RestKit

于 2013-02-01T09:25:38.297 回答