Skip to content

Instantly share code, notes, and snippets.

@enigmaticape
Created May 21, 2014 18:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save enigmaticape/335800709e3a9ca69b10 to your computer and use it in GitHub Desktop.
Save enigmaticape/335800709e3a9ca69b10 to your computer and use it in GitHub Desktop.
Determine if Wi-Fi is enabled on iOS with this one weird trick.
struct ifaddrs *interfaces;
if(!getifaddrs(&interfaces)) {
for( struct ifaddrs *interface = interfaces; interface; interface=interface->ifa_next) {
BOOL up = (interface->ifa_flags & IFF_UP) == IFF_UP;
if ( up ) {
NSLog(
@"Name : %s, sa_family : %d",
interface->ifa_name,
interface->ifa_addr->sa_family
);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment