Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I convert HTML NSData to an NSString?

I'm using [NSData dataWithContentsOfURL:] to create two NSData instances and I want to compare these instances to gauge how different they are. Since they're both from the same website, using a string to find what is different will help me highlight the actual element(s) that has (have) changed. Is it possible to change this data to a string to find the difference?

like image 455
Carter Pape Avatar asked Jul 16 '11 20:07

Carter Pape


2 Answers

Try initWithData:encoding: method of NSString to create string with your data.

Exmp: NSString *str = [[NSString alloc] initWithData:someData encoding:NSUTF8StringEncoding]

like image 64
VenoMKO Avatar answered Sep 29 '22 20:09

VenoMKO


Why don't you use NSString stringWithContentsOfURL:encoding:error:

like image 44
Pencho Ilchev Avatar answered Sep 29 '22 22:09

Pencho Ilchev