AFNetworking 2.0 Reachability
That's because that block is only executed when reachability changes.
To get the current status, you can do this:
- (BOOL)connected {
return [AFNetworkReachabilityManager sharedManager].reachable;
}
Setting up reachability with AFNetworking 2.0
As you can read in the AFNetworking read me page
[[AFNetworkReachabilityManager sharedManager] setReachabilityStatusChangeBlock:^(AFNetworkReachabilityStatus status) {
NSLog(@"Reachability: %@", AFStringFromNetworkReachabilityStatus(status));
}];
Here's also a link to the official documentation.
AFNetworking 2.0 Reachability not working
I needed to start the reachability monitor.
[self.manager.reachabilityManager startMonitoring];
I find it by accident, documentation should state this in my opinion.
AFNetworking reachability status not changing
This is because a 100% loss situation isn't equal to doesn't have a connection at all. 100% loss means that all of the packets are dropped but the network connection still exists, it is usefull when you want to simulate a timeout connection.
In order to simulate the no network case you should turn your wifi connection off on your mac or iDevice, for simulator or physical device.
Monitoring Reachability with AFNetworking only on a presented controller
Unfortunately no, there isn't an easier way to do this.
However, the plan you mentioned doesn't sound all that bad. You essentially are asking the manager to turn it's notifications off and on, and it needs you to tell it when to do so.
Here's how I do it:
- (void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
[manager startMonitoring];
}
- (void)viewWillDisappear:(BOOL)animated
{
[super viewWillDisappear:animated];
[manager stopMonitoring];
}
Related Topics
Set Uitableview Content Inset Permanently
Get Latitude/Longitude from Address
Swift - Segmented Control - Switch Multiple Views
Detecting Active Avaudiosessions on iOS Device
Sensitivity/Scroll Speed of Uiscrollview with Paging
How to Programmatically Check Support of 'Face Id' and 'Touch Id'
Safeareainsets in Uiview Is 0 on an iPhone X
iOS - Detect Blow into Mic and Convert the Results! (Swift)
Mfmessagecomposeviewcontroller iOS7 Addattachmentdata:Typeidentifier:Filename: Not Working
Toplayoutguide in Child View Controller
Module Was Not Compiled for Testing' When Using @Testable
Alternative Ways to Push View Controllers with Storyboard Programmatically
How to Get the Custom Overlay for Uiimagepicker Camera to Be Full Screen in iOS 7