我正在使用这段代码来检查我的应用程序中的网络连接,如果存在连接,则提取数据并显示它:
if([[Reachability reachabilityForInternetConnection] currentReachabilityStatus] == NotReachable) {
errorView = [[UIAlertView alloc]
initWithTitle: @"Network Error"
message: @"No Network connection availible!"
delegate: self
cancelButtonTitle: @"OK" otherButtonTitles: nil];
[errorView show];
}
else
{
HUD = [[MBProgressHUD alloc] initWithView:self.navigationController.view];
[self.navigationController.view addSubview:HUD];
HUD.delegate = self;
HUD.labelText = @"Performing Initial Download";
HUD.minSize = CGSizeMake(135.f, 135.f);
[HUD showWhileExecuting:@selector(pullAndDisplayData) onTarget:self withObject:nil animated:YES];
}
但是,我想修改此代码,以便它在整个下载过程中不断检查互联网连接,如果我失去连接,则停止下载并向用户显示适当的警报消息。任何人都可以建议我如何解决这个问题吗?
谢谢,
泰辛