【发布时间】:2012-06-03 13:10:47
【问题描述】:
我有以下代码。
NSURL *serverUrl = [NSURL URLWithString:@"http://google.com"];
NSError *error = nil;
NSString *stringFromStream = [NSString stringWithContentsOfURL:serverUrl encoding:NSUTF8StringEncoding error:&error];
NSLog(@"string is %@ error is %@", stringFromStream, error);
这段代码产生以下错误
2012-05-29 11:57:46.914 [2221:f803] string is (null) error is Error Domain=NSCocoaErrorDomain Code=261 "The operation couldn’t be completed. (Cocoa error 261.)" UserInfo=0x6a36c60 {NSURL=http://google.com, NSStringEncoding=4}
但是如果我将 URL 更改为
NSURL *serverUrl = [NSURL URLWithString:@"http://apple.com"];
我会完美地工作。
【问题讨论】:
-
完全相同的代码在我的 mac 中工作:O
标签: objective-c nsstring nsurl