NSData *responseData = [NSURLConnection sendSynchronousRequest:theRequest returningResponse:&response error:&error];
NSString *data = [[NSString alloc] initWithData:urlData encoding:NSUTF8StringEncoding];
Can you please explain me the purpose of NSUTF8StringEncoding, does it encode the whole data? Can you give an example of NSUTF8StringEncoding with an input and output?
You have to tell NSString using which encoding can the bytes of the NSData be interpreted as a valid string. It won’t, however, modify/convert your string between encodings. If the NSData object contains a byte sequence which is not valid UTF-8, it will simply return nil.