I’m sending XML request to some server and getting some response data from it using NSURLConnection:
-(void)connectionDidFinishLoading:(NSURLConnection *)connection
{
NSMutableString *receivedString = [[NSMutableString alloc] initWithData:_receivedData encoding:NSUTF8StringEncoding];
NSLog(@"Size of DATA: %d",[_receivedData length]);
NSLog(@"Body: %@", receivedString);
}
When length of my data is about 4000 – I can normally see the received data in output. But when length of data becomes greater (6000, 10000, etc.), Output shows that my receivedString becomes null!
How can I still save my data to the string, when it’s length becomes greater? Thank you.
Are you sure your data is encoded with
NSUTF8StringEncoding? Double check the data being returned to you.initWithData:encoding:will returnnilif the data is not properly represented by the encoding.An easy way to test this is to use the same data object, and create a string with incremental pieces of the same data until it fails, then look at the byte that causes it to fail.
I’d bet a piece of southern fried catfish that you have an improperly (or mismatched) encoded byte in that data.