iOS – Check if wifi is being used
In an app I was making recently I wanted to check if the user was using a wifi connection. I used the method below to check and just checked whether it returned true or false.
- (BOOL)networkCheck{ Reachability *currentReachability = [[Reachability reachabilityForInternetConnection] retain]; NetworkStatus networkStatus = [currentReachability currentReachabilityStatus]; [currentReachability release]; switch (networkStatus) { case NotReachable: { NSLog(@"Not connected"); return false; break; } case ReachableViaWWAN:{ NSLog(@"Cellular Network"); return false; break; } case ReachableViaWiFi:{ NSLog(@"Wifi"); return true; break; } } return false; } |