【发布时间】:2011-09-04 04:43:15
【问题描述】:
我正在尝试使用stringWithContentsOfURL: 从网络获取 HTML 文件。我的问题是,有时它有效,但有时无效。例如,我试过:
NSString *string = [NSString stringWithContentsOfURL:
[NSURL URLWithString:@"http://www.google.com/"]
encoding:encoding1
error:nil];
NSLog(@"html = %@",string);
这很好用,但是当我用@"http://www.youtube.com/" 替换 URL 时,我只会得到“NULL”。有没有人知道发生了什么?是因为 YouTube 有某种保护吗?
【问题讨论】:
-
您尝试过哪些其他网址?这可能是加载延迟。
标签: objective-c cocoa-touch ios nsurl