【问题标题】:Get security type of currently connected wifi network for Mac OS X using cocoa使用可可获取 Mac OS X 当前连接的 wifi 网络的安全类型
【发布时间】:2011-09-02 13:00:28
【问题描述】:
我需要在 Mac 上找到当前连接网络的安全类型(例如 WPA2、WEP)。
我的目标是 Mac OS 10.3。似乎这可以使用 SCDynamicStore API 来完成。但是,我无法解决这个问题。此外,我需要将应用程序提交到 Mac App Store,因此不想使用任何私人代码。任何指针或示例代码都会非常有帮助。
提前致谢。
【问题讨论】:
标签:
objective-c
macos
cocoa
networking
wireless
【解决方案1】:
#import <CoreWLAN/CoreWLAN.h>
CWInterface* wifi = [[CWWiFiClient sharedWiFiClient] interface];
NSString *securityType = [wifi security];// this is given you enum(some number) and u can do function that return the correct string with the name according this enum
这是枚举:
typedef NS_ENUM(NSInteger, CWSecurity)
{
kCWSecurityNone = 0,
kCWSecurityWEP = 1,
kCWSecurityWPAPersonal = 2,
kCWSecurityWPAPersonalMixed = 3,
kCWSecurityWPA2Personal = 4,
kCWSecurityPersonal = 5,
kCWSecurityDynamicWEP = 6,
kCWSecurityWPAEnterprise = 7,
kCWSecurityWPAEnterpriseMixed = 8,
kCWSecurityWPA2Enterprise = 9,
kCWSecurityEnterprise = 10,
kCWSecurityUnknown = NSIntegerMax,
} NS_ENUM_AVAILABLE_MAC(10_7);