Iphone 苹果文档中的简单NSURL不起作用?
好的,这里没有什么特别的,没有错误,我声明Iphone 苹果文档中的简单NSURL不起作用?,iphone,objective-c,Iphone,Objective C,好的,这里没有什么特别的,没有错误,我声明NSMutableData*receivedData 但是当我期待一个网页返回时,我正在返回;发生什么事了 - (void)viewDidLoad { [super viewDidLoad]; NSURLRequest *theRequest=[NSURLRequest requestWithURL:[NSURL URLWithString:@"http://www.apple.com"]
NSMutableData*receivedData代码>
但是当我期待一个网页返回时,我正在返回;发生什么事了
- (void)viewDidLoad {
[super viewDidLoad];
NSURLRequest *theRequest=[NSURLRequest requestWithURL:[NSURL URLWithString:@"http://www.apple.com"]
cachePolicy:NSURLRequestUseProtocolCachePolicy
timeoutInterval:60.0];
NSURLConnection *theConnection = [[NSURLConnection alloc] initWithRequest:theRequest delegate:self];
if (theConnection) {
receivedData = [[NSMutableData data] retain];
NSLog(@"receivedData %@", receivedData);
} else {
// inform the user that the download could not be made
}
}
您似乎指的是。。。但看起来您在复制代码示例之后就停止了阅读。阅读下一节。您创建数据对象只是为了“捕获”传入数据。需要更多的代码来实际处理响应并将其放入数据对象中。毫不奇怪,事后立即记录的结果一无所获。是的,天哪,我觉得自己很傻。添加了代理,最后我吐出了一堆字节,假设只需要将它们转换为可读文本。