Last active
December 15, 2015 06:39
-
-
Save PrzemekMalak/5217531 to your computer and use it in GitHub Desktop.
Get Current WiFi Network
This file contains 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
+(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