Reputation: 1654
I develop an app and some areas are required to be connected to internet generally. Not important how: 3G,Wifi.
So, my question is do I have to use reachability on the main view or I can implement it only in the specific areas where the internet connection is required?
Thank you in advance.
Upvotes: 0
Views: 202
Reputation: 6891
I'm pretty sure it can be implemented wherever you need it.
All you have to do:
Then, wherever you want it...
Include it with:
#import "Reachability.h"
Write a method to call:
-(BOOL)reachable {
Reachability *r = [Reachability reachabilityWithHostName:@"enbr.co.cc"];
NetworkStatus internetStatus = [r currentReachabilityStatus];
if(internetStatus == NotReachable) {
return NO;
}
return YES;
}
Call it:
if ([self reachable]) {
NSLog(@"Reachable");
}
else {
NSLog(@"Not Reachable");
}
Upvotes: 2