【发布时间】:2014-11-28 12:37:31
【问题描述】:
我正在尝试找出最合适的方法来处理在UIWebView 中加载页面时可能发生的错误。
如果我发现网络相关问题或服务器相关问题,我想提醒用户。我无法找到有关要检查的特定错误代码的任何详细信息。这就是我现在拥有的:
NSInteger errorCode = [error code];
NSString* title = nil;
NSString* message = nil;
if (errorCode == NSURLErrorNetworkConnectionLost || errorCode == NSURLErrorNotConnectedToInternet) {
title = @"Error";
message = @"The network connection appears to be offline.";
}
if (errorCode == NSURLErrorTimedOut || errorCode == NSURLErrorBadServerResponse) {
title = @"Error";
message = @"There was an error loading the request. Please try again later.";
}
if (title != nil) {
UIAlertView* alert = [[UIAlertView alloc] initWithTitle:title message:message delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
alert.tag = TAG_WEB_ERROR;
[alert show];
}
我是否正在检查正确的错误代码?关于检查和处理潜在错误的更好方法有什么想法吗?
【问题讨论】:
标签: ios