In 4th sections there's an example of wrapper for Reachability (but in that realization there's no kReachabilityChangedNotification handling). So how should you use it? — As you can see in interface of MTReachabilityManager, there're 1 method for getting singleton instance of manager and 4 methods for working with it:
+ (BOOL)isReachable;
+ (BOOL)isUnreachable;
+ (BOOL)isReachableViaWWAN;
+ (BOOL)isReachableViaWiFi;
For your second approach in method that want connection You have to do something like:
if ([[MTReachabilityManager sharedManager] isReachable]) {
//do internet
} else {
//alert 'no internet' or something
}
For first approach (connection was lost during getting data from network) this wrapper would not help you (not implemented listening of kReachabilityChangedNotification). So you have to add code from section 3 (Step 3: Notifications) of this tutorial — add listener for kReachabilityChangedNotification somewhere before call network code:
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(reachabilityDidChange:) name:kReachabilityChangedNotification object:nil];
and add method to handle notifications (will be fired when internet changed it's state):
- (void)reachabilityDidChange:(NSNotification *)notification {
Reachability *reachability = (Reachability *)[notification object];
if ([reachability isReachable]) {
NSLog(@"Reachable");
//if before there was no internet - now you can do whatever user wants when there was no internet
} else {
NSLog(@"Unreachable");
//alert retry
}
}