I\'ve been trying to come up with a solution to queue HTTP requests using AFNetworking when the device is offline, so when it goes back online the requests gets done. As far
You do not store manager
. So it is like any local variable is deleted when leaving viewDidLoad. Store it to property or instance variable.
You need to call startMonitoring, before you call setReachabilityStatusChangeBlock
[manager.reachabilityManager startMonitoring];
If you are using AFNetworking 2.0, I suggest following:
[[AFNetworkReachabilityManager sharedManager] startMonitoring];
[[AFNetworkReachabilityManager sharedManager] setReachabilityStatusChangeBlock:^(AFNetworkReachabilityStatus status) {
DLog(@"Reachability: %@", AFStringFromNetworkReachabilityStatus(status));
switch (status) {
case AFNetworkReachabilityStatusReachableViaWWAN:
case AFNetworkReachabilityStatusReachableViaWiFi:
[operationQueue setSuspended:NO];
NSLog(@"WIFI");
break;
case AFNetworkReachabilityStatusNotReachable:
default:
[operationQueue setSuspended:YES];
NSLog(@"offline, baby");
break;
}
}];