Last active
August 29, 2015 14:02
-
-
Save nakiwo/e5e28124afbe4d32b490 to your computer and use it in GitHub Desktop.
SSID取得
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
@import SystemConfiguration; | |
#import <SystemConfiguration/CaptiveNetwork.h> | |
- (NSString *)currentSSID | |
{ | |
NSArray *interfaceNames = CFBridgingRelease(CNCopySupportedInterfaces()); | |
if (!interfaceNames.count) { | |
return nil; | |
} | |
NSString *interfaceName = interfaceNames.firstObject; | |
if (!interfaceName) { | |
return nil; | |
} | |
NSDictionary *info = CFBridgingRelease(CNCopyCurrentNetworkInfo((__bridge CFStringRef)interfaceName)); | |
NSString *ssid = info[(__bridge NSString *)kCNNetworkInfoKeySSID]; | |
return ssid; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment