ios 后台返回的是个字符 怎么解析 用afnetworking
1个回答
展开全部
代码:
AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];
//申明返结json类型
manager.responseSerializer = [AFJSONResponseSerializer serializer];
//申明请求数据json类型
manager.requestSerializer=[AFJSONRequestSerializer serializer];
//报接受类型致请替换致text/html或别
manager.responseSerializer.acceptableContentTypes = [NSSet setWithObject:@"text/html"];
//传入参数
NSDictionary *parameters = @{@"1":@"XXXX",@"2":@"XXXX",@"3":@"XXXXX"};
//接口址
NSString *url=@"";
//发送请求
[manager POST:url parameters:parameters success:^(AFHTTPRequestOperation *operation, id responseObject) {
NSLog(@"JSON: %@", responseObject);
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
NSLog(@"Error: %@", error);
}];
AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];
//申明返结json类型
manager.responseSerializer = [AFJSONResponseSerializer serializer];
//申明请求数据json类型
manager.requestSerializer=[AFJSONRequestSerializer serializer];
//报接受类型致请替换致text/html或别
manager.responseSerializer.acceptableContentTypes = [NSSet setWithObject:@"text/html"];
//传入参数
NSDictionary *parameters = @{@"1":@"XXXX",@"2":@"XXXX",@"3":@"XXXXX"};
//接口址
NSString *url=@"";
//发送请求
[manager POST:url parameters:parameters success:^(AFHTTPRequestOperation *operation, id responseObject) {
NSLog(@"JSON: %@", responseObject);
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
NSLog(@"Error: %@", error);
}];
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询