我使用 AFNetworking 编写一个 RESTful 客户端。然后使用 JSONKit 将响应数据解析为 NSDictionary。
例子:
- (void)postPath:(NSString *)path
parameters:(NSDictionary *)parameters
success:(void (^)(AFHTTPRequestOperation *operation, id responseObject, NSDictionary* jsonDictionary))success
failure:(void (^)(AFHTTPRequestOperation *operation, NSError *error))failure
{
[self.client postPath:path parameters:parameters success:^(AFHTTPRequestOperation *operation, id responseObject) {
NSDictionary* jsonDictionary = [self.jsonDecoder objectWithData:responseObject];
// do the object-mapping works
success(operation, responseObject, jsonDictionary);
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
failure(failure, error);
}];
}
如何使用 RESTKit 中的 RKObjectMapping 作为独立库来进行对象映射?提前致谢。