我正在使用AFNetwork 3.0进行HTTP get请求.
我甚至得到了回应.但我想将响应数据作为NSString.
有人可以帮助我如何获取响应数据作为NSString
我甚至得到了回应.但我想将响应数据作为NSString.
有人可以帮助我如何获取响应数据作为NSString
这是我的代码,
AFHTTPSessionManager *operation = [AFHTTPSessionManager alloc]; [operation GET:controlURL.absoluteString parameters:nil progress:nil success:^(NSURLSessionTask *task,id responSEObject) { NSLog(@"JSON: %@",responSEObject); NSLog(@"success: %@",responSEObject); NSString *xmlString = [responSEObject ];// i am facing problem here
解决方法
如果您想在字符串中使用响应数据,请尝试以下操作:
NSString *str = [[NSString alloc] initWithData:responSEObject encoding:NSUTF8StringEncoding]; NSLog(@"responseData: %@",str);