切换机场可可

时间:2011-02-14 17:17:06

标签: objective-c cocoa macos

有没有办法使用Cocoa切换机场?

1 个答案:

答案 0 :(得分:6)

使用CoreWLAN框架。要禁用界面,

#import <CoreWLAN/CoreWLAN.h>

NSError *error = nil;
CWInterface *wif = [CWInterface interface];
BOOL setPowerSuccess = [wif setPower:NO error:&error];
if (! setPowerSuccess) {
    NSLog(@"error whilst disabling airport: %@", error);
}

要启用界面,请将YES传递给-setPower:error: