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?
Add a comment |
2 Answers
Why don't you use NSString stringWithContentsOfURL:encoding:error:
2 Comments
Williham Totland
@caterpape: Whatever encoding the text is in to begin with. But I'd probably recommend non-lossy ASCII since you are just comparing two strings anyway.
Pencho Ilchev
As @william-totland mentioned start with NSASCIIStringEncoding and consider revising if the output does not satisfy you (you work with non-ascii data, e.g. Russian, Chinese, etc).