Convert NSData to NSString with
NSString *strData = [[NSString alloc]initWithData:returnData encoding:NSUTF8StringEncoding];
and type NSString in NSLog as below
NSLog(@"%@",strData);
This answer is being edited for JeremyP since it does not know how to know that the content has UTF-8, although this was not a discussion of this issue.
You can get the response header in the following delegate method
- (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response { NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *)response; NSDictionary *dic = [httpResponse allHeaderFields]; }
This dictionary will give you all the header information as shown below.
<CFBasicHash 0x5a45e40 [0x24b2380]>{type = immutable dict, count = 7, entries => 0 : <CFString 0x5d1bf60 [0x24b2380]>{contents = "X-Aspnet-Version"} = <CFString 0x5d21a60 [0x24b2380]>{contents = "2.0.50727"} 1 : <CFString 0x41a03a8 [0x24b2380]>{contents = "Server"} = <CFString 0x5d272f0 [0x24b2380]>{contents = "Microsoft-IIS/6.0"} 2 : <CFString 0x41a0010 [0x24b2380]>{contents = "Content-Length"} = <CFString 0x5d28630 [0x24b2380]>{contents = "385"} 6 : <CFString 0x419ff48 [0x24b2380]>{contents = "Cache-Control"} = <CFString 0x5d29c70 [0x24b2380]>{contents = "private, max-age=0"} 10 : <CFString 0x5d1c640 [0x24b2380]>{contents = "X-Powered-By"} = <CFString 0x5d26f10 [0x24b2380]>{contents = "ASP.NET"} 11 : <CFString 0x41a0060 [0x24b2380]>{contents = "Content-Type"} = <CFString 0x5d29c90 [0x24b2380]>{contents = "text/xml; charset=utf-8"} 12 : <CFString 0x41a0088 [0x24b2380]>{contents = "Date"} = <CFString 0x5d27610 [0x24b2380]>{contents = "Fri, 08 Jul 2011 15:23:10 GMT"} }
Check charset = "utf-8", you will get the encoding from here.
iMOBDEV Jul 08 2018-11-11T00: 00Z
source share