Last active
August 16, 2017 10:21
-
-
Save czwen/76a26fd9513d8d74be3723c64e17ae55 to your computer and use it in GitHub Desktop.
check wifi toggle status
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import <ifaddrs.h> | |
#import <net/if.h> | |
- (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; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment