Toggle Airport Cocoa
Is there any way of toggling开发者_开发知识库 Airport using Cocoa?
Use the CoreWLAN framework. To disable the interface,
#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);
}
To enable the interface, pass YES
to -setPower:error:
.
精彩评论