使用cocoa获取Mac OS X当前连接的wifi网络的安全类型

时间:2011-09-02 13:00:29

标签: objective-c macos cocoa networking wireless

我需要在Mac上找到当前连接网络的安全类型(例如WPA2,WEP)。 我的目标是Mac OS 10.3。似乎可以使用SCDynamicStore API完成此操作。但是,我无法找到解决这个问题的方法。此外,我需要将应用程序提交到Mac App Store,因此不想使用任何私有代码。任何指针或示例代码都会非常有用。 提前谢谢。

1 个答案:

答案 0 :(得分: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

这是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);