0
我有以下代碼。URLWithString「http://google.com」VS URLWithString「http://apple.com」
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"];
我會很好地工作。
這有點兒有趣:-) – Adam
完全相同的代碼在我的mac中工作:O – fbernardo