Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/23.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Iphone 苹果文档中的简单NSURL不起作用?_Iphone_Objective C - Fatal编程技术网

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
    }
}

您似乎指的是。。。但看起来您在复制代码示例之后就停止了阅读。阅读下一节。您创建数据对象只是为了“捕获”传入数据。需要更多的代码来实际处理响应并将其放入数据对象中。毫不奇怪,事后立即记录的结果一无所获。

是的,天哪,我觉得自己很傻。添加了代理,最后我吐出了一堆字节,假设只需要将它们转换为可读文本。