求解,怎么用AFNetworking 2.0 发送JSON到服务器请求数据
1个回答
展开全部
AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];
manager.responseSerializer = [AFJSONResponseSerializer serializer];//json解析
manager.responseSerializer.acceptableContentTypes = [NSSet setWithObject:@"text/html"];//台格式问题用行解决定必须
[manager POST:urlString parameters:params success:^(AFHTTPRequestOperation *operation, id responseObject) {
NSLog(@"POST请求完");
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
NSLog(@"POST请求失败: %@", error);
}];
postget类似
manager.responseSerializer = [AFJSONResponseSerializer serializer];//json解析
manager.responseSerializer.acceptableContentTypes = [NSSet setWithObject:@"text/html"];//台格式问题用行解决定必须
[manager POST:urlString parameters:params success:^(AFHTTPRequestOperation *operation, id responseObject) {
NSLog(@"POST请求完");
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
NSLog(@"POST请求失败: %@", error);
}];
postget类似
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询