试图用NSData解析简单的URL,但失败了:
NSURL* url = [[NSURL alloc] initWithString:@"http://192.168.2.105:80"];
NSData* data = [NSData dataWithContentsOfURL:url options:NSDataReadingUncached error:&error];结果是error = Cocoa误差256
什么原因?
发布于 2012-12-13 14:40:07
看看这个:
NSURL* URL=[NSURL URLWithString: @"http://www.google.com"];
NSURLRequest* req=[NSURLRequest requestWithURL: URL];
NSData* data=[NSURLConnection sendSynchronousRequest: req returningResponse: nil error: nil];这是一个简短的例子,我建议查看响应和最终的错误。
编辑
使用dataWithContentOfURL是正确的,我发布的代码也是如此。
但这是wrong.You的URL,应该传递类似于http://www.site.org的内容。
https://stackoverflow.com/questions/13861287
复制相似问题