How to get response string from NSURLSessionTask

I am using AFNetwork 3.0 to request an HTTP request. I even get an answer. But I want to get the response data as NSString. Can someone please help me how to get response data asNSString

Here is my code

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
source share
1 answer

If you need response data in your line, try the following:

        NSString *str = [[NSString alloc] initWithData:responseObject encoding:NSUTF8StringEncoding];
    NSLog(@"responseData: %@", str);
0
source

All Articles