Skip to content

Instantly share code, notes, and snippets.

@mlabraca
Created August 13, 2015 11:12
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 mlabraca/83ea7ba3b4f2ce590404 to your computer and use it in GitHub Desktop.
Save mlabraca/83ea7ba3b4f2ce590404 to your computer and use it in GitHub Desktop.
Get Wifi network information in Objective-C
/** Returns first non-empty SSID network info dictionary.
* @see CNCopyCurrentNetworkInfo
* remember to import this:
* @import SystemConfiguration.CaptiveNetwork;
**/
+ (id)fetchSSIDInfo {
NSArray *ifs = (__bridge_transfer NSArray *)CNCopySupportedInterfaces();
//NSLog(@"Supported interfaces: %@", ifs);
NSDictionary *info;
for (NSString *ifnam in ifs) {
info = (__bridge_transfer NSDictionary *)CNCopyCurrentNetworkInfo((__bridge CFStringRef)ifnam);
//NSLog(@"%@ => %@", ifnam, info);
if (info && [info count]) { break; }
}
return info;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment