#import "someClass.h"
@implementation someClass
- (NSInteger *)checkWakeOnLan {
SCDynamicStoreRef ds = SCDynamicStoreCreate(kCFAllocatorDefault, CFSTR("myapp"), NULL, NULL);
CFDictionaryRef dr = SCDynamicStoreCopyValue(ds, CFSTR("State:/IOKit/PowerManagement/CurrentSettings"));
CFNumberRef wol=CFDictionaryGetValue(dr, CFSTR("Wake On LAN"));
CFRelease(dr);
CFRelease(ds);
这是我的问题,如何将 CFNumberRef 转换为 NSInteger,我一次又一次地尝试,但随时得到“从指针生成整数而不进行强制转换”
NSInteger *value = [... ?];
return value;
}
- (IBAction)doStuff:(NSButton *)sender {
[myBevelButton setState:[self checkWakeOnLan]]; //setState takes NSInteger
//myBevelButton defined elsewhere, shows different icons
}
@end