如何将 HTML NSData 转换为 NSString? [英] How do I convert HTML NSData to an NSString?

查看:42
本文介绍了如何将 HTML NSData 转换为 NSString?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 [NSData dataWithContentsOfURL:] 创建两个 NSData 实例,我想比较这些实例以判断它们的不同之处.由于它们都来自同一个网站,因此使用字符串查找不同之处将有助于我突出显示已更改的实际元素.是否可以将此数据更改为字符串以查找差异?

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?

推荐答案

尝试使用 NSString 的 initWithData:encoding: 方法用你的数据创建字符串.

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

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

这篇关于如何将 HTML NSData 转换为 NSString?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆