我有这段代码:
- (void)connection:(NSURLConnection*)connection didReceiveResponse:(NSURLResponse*)response
{
if ([response respondsToSelector:@selector(statusCode)]) {
int statusCode = [((NSHTTPURLResponse*)response) statusCode];
if (statusCode >= 400) {
NSError* statusError = [NSError errorWithDomain:@"Server connection error" code:statusCode userInfo:nil];
[self connection:connection didFailWithError:statusError];
}
}
}
- (void)connection:(NSURLConnection*)connection didFailWithError:(NSError*)error
{
NSLog(@"%@", [error localizedDescription]);
}
这给出了一个缺失的页面:
--> 操作无法完成。(服务器连接错误错误 404。)
该描述(本地化与否)来自哪里?
我刚刚用一个代码和一个自定义的无意义的域字符串初始化了 NSError ......