I use the code snippet below to determine if Wi-Fi is on or not. This code works great on iPad Air or
(BOOL) isWiFiEnabled {
NSCountedSet * cset = [NSCountedSet new];
struct ifaddrs *interfaces;
if( ! getifaddrs(&interfaces) ) {
for( struct ifaddrs *interface = interfaces; interface; interface = interface->ifa_next) {
if ( (interface->ifa_flags & IFF_UP) == IFF_UP ) {
[cset addObject:[NSString stringWithUTF8String:interface->ifa_name]];
}
}
}
return [cset countForObject:@"awdl0"] > 1 ? YES : NO;
}
For the iPad 2 model, this code does not work, that is, it returns 0. Please help me with this, for example, any other way to detect Wi-Fi on this model.
This issue is specific to iPad 2 only, and I already mentioned that it works great for iPad Air and other models.
source
share