无法检索字符串中的数据

时间:2010-07-29 06:26:07

标签: iphone objective-c nsstring

self.pdfPath = [[NSBundle mainBundle] pathForResource:@"iPhone_SDK_License" ofType:@"pdf"];
NSData *htmlData = [NSData dataWithContentsOfFile:pdfPath];
NSString *htmlstr = [[NSString alloc] initWithData:htmlData encoding:NSUTF8StringEncoding];

它在htmlstr中显示为nil,因此需要一些帮助。

1 个答案:

答案 0 :(得分:0)

pdf不是一个html文件,所以我假设initWithData:encoding:无法理解数据,因此失败。

使用stringWithContentsOfURL:encoding:error:查看错误的详细信息。