I am parsing a URL, I am getting some data in a NSMutableData object i.e urlData. Now in - (void)connectionDidFinishLoading:(NSURLConnection *)connection {} I would like to convert the urlData to a NSString. I have tried with:
NSString *responseData = [NSString stringWithCString:[urlData bytes] length:[urlData length]];
NSString* responseData = [NSString stringWithUTF8String:[urlData bytes]];
NSString *responseData = [[NSString alloc] initWithBytes:[urlData bytes] length:[urlData length] encoding:NSUTF8StringEncoding] ;
NSString *responseData = [[NSString alloc] initWithData:urlData encoding:NSASCIIStringEncoding];
NSString *responseData = [[NSString alloc] initWithData:urlData encoding:NSUTF8StringEncoding];
I am either getting null in NSString object or PK(reverse Question Marks which i am unable to show you).
Can anyone give me a solution for this?
is the method you need to use. Your problem is either that you are not using the correct encoding or the data is not string data. NSLog the data and examine it to figure pout what it really is.
From the Apple documents: