Skip to content

Instantly share code, notes, and snippets.

@PrzemekMalak
Last active December 15, 2015 06:39
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 PrzemekMalak/5217531 to your computer and use it in GitHub Desktop.
Save PrzemekMalak/5217531 to your computer and use it in GitHub Desktop.
Get Current WiFi Network
+(NSDictionary *) getCurrentNetwork
{
NSMutableDictionary *_hn;
NSArray *netArray = (__bridge_transfer id)CNCopySupportedInterfaces();
id info = nil;
for (NSString *netName in netArray)
{
info = (__bridge_transfer id)CNCopyCurrentNetworkInfo((__bridge CFStringRef)netName);
NSDictionary *infoDictionary = (NSDictionary*) info;
_hn = [[NSMutableDictionary alloc] initWithCapacity:2];
if (infoDictionary != nil)
{
[_hn setObject:[infoDictionary valueForKey:@"SSID"] forKey:@"SSID"];
[_hn setObject:[infoDictionary valueForKey:@"BSSID"] forKey:@"MAC"];
}
if (info && [info count])
{
break;
}
}
return _hn;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment