我想解析html..所以我找到了一些示例代码:http://blog.objectgraph.com/index.php/2010/02/24/parsing-html-iphone-development/,它使用hpple来解析html...但是有一个问题,这个应用程序由于某种原因经常崩溃,最有可能的是这里的这一行:
NSURL *url = [NSURL URLWithString: @"http://www.objectgraph.com/contact.html"];
NSString *contents = [NSString stringWithContentsOfURL:url];
NSData *htmlData = [contents dataUsingEncoding:NSUTF8StringEncoding];xCode警告我stringWithCOntentsofVariable已弃用..
那么有没有人能帮我解决这个problem....by,告诉我应该修改什么代码?
谢谢
发布于 2011-03-10 13:49:35
the documentation中的30秒显示:
返回一个字符串,该字符串是通过从给定URL命名的文件中读取数据而创建的。(在Mac OS X v10.4中已弃用。请改用
stringWithContentsOfURL:encoding:error:或stringWithContentsOfURL:usedEncoding:error:。)
因此,看起来您应该使用stringWithContentsOfURL:encoding:error或stringWithContentsOfURL:usedEncoding:error:。
就像文档上说的那样。
https://stackoverflow.com/questions/5255850
复制相似问题