【发布时间】:2014-10-27 01:50:18
【问题描述】:
我尝试从 URL 中获取一些文本并将其放在 UITextView 中。
那是我在ViewController 中的代码:
NSString *urlString = @"http:/...";
NSError *error = nil;
NSData *dataURL = [NSData dataWithContentsOfURL:[NSURL URLWithString:urlString] options:kNilOptions error:&error];
if (error)
NSLog(@"%s: dataWithContentsOfURL error: %@", __FUNCTION__, error);
else
{
NSString *result = [[NSString alloc] initWithData:dataURL encoding:NSUTF8StringEncoding];
NSLog(@"%s: result = %@", __FUNCTION__, result);
// if you were updating a label with an `IBOutlet` called `resultLabel`, you'd do something like:
self.mytextview.text = result;
}
现在模拟器在我的视图中显示该文本:
对不起,文字是德语:)
现在如何隐藏或删除该 html、head、body 等?
【问题讨论】:
标签: ios iphone xcode nsdata nsurl