I am using Reachability Code of Tony Million and in the unreachable block i am trying to pause the download but each time the internet Disconnects before the download is paused AFNetworking returns with failure with error message "The network connection was lost" thus unable to resume the download so what should be Done?
This is what i have done in Application Delegate
__weak MTCAppDelegate *weakself = self;
Reachability * reach = [Reachability reachabilityWithHostname:@"www.google.com"];
reach.reachableBlock = ^(Reachability * reachability)
{
dispatch_async(dispatch_get_main_queue(), ^{
[[AFDROSingleton sharedInstance] resume];
for (UIView *subview in [weakself.window subviews]) {
if (subview.tag == 20) {
[subview removeFromSuperview];
}
}
});
};
reach.unreachableBlock = ^(Reachability * reachability)
{
dispatch_async(dispatch_get_main_queue(), ^{
MTCReachability *reach = [[MTCReachability alloc] initWithFrame:weakself.window.frame];
[reach setTag:20];
[weakself.window addSubview:reach];
[weakself.window bringSubviewToFront:reach];
[[AFDROSingleton sharedInstance] pause];
});
};
[reach startNotifier];
There is reachability code from the Apple sample that has been updated to ARC.
I've put it into the Reachability project in Xcode 4.6.3. If you are interested I can send your way if you need it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With