4

我将 AFNetwork 3.0 用于 HTTP 获取请求。我什至得到了回应。但我想将响应数据作为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
4

1 回答 1

0

如果您想要字符串中的响应数据,请尝试以下操作:

        NSString *str = [[NSString alloc] initWithData:responseObject encoding:NSUTF8StringEncoding];
    NSLog(@"responseData: %@", str);
于 2016-05-16T12:17:07.643 回答