开发者

How do I convert HTML NSData to an NSString?

开发者 https://www.devze.com 2023-03-21 05:57 出处:网络
I\'m using [NSData dataWithContentsOfURL:] to create two NSData instances and I want to compare t开发者_Go百科hese instances to gauge how different they are. Since they\'re both from the same website,

I'm using [NSData dataWithContentsOfURL:] to create two NSData instances and I want to compare t开发者_Go百科hese 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?


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

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


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

0

精彩评论

暂无评论...
验证码 换一张
取 消