如何从IO工具包导入IOPMLib.h?

时间:2011-02-06 01:40:25

标签: objective-c cocoa iokit

我正在尝试使用以下代码唤醒Mac,

CFAbsoluteTime currentTime = CFAbsoluteTimeGetCurrent();
CFDateRef wakeFromSleepAt = CFDateCreate(NULL, currentTime + 60);
IOReturn returnCode = IOPMSchedulePowerEvent(wakeFromSleepAt, NULL, CFSTR(kIOPMAutoWakeOrPowerOn));

我无法找到要导入的正确框架/标头。

我正在使用#import <IOKit/pwr_mgt/IOPMLib.h>,但编译器仍然抱怨。有什么建议?感谢。

编辑

我收到以下错误消息

Undefined symbols:
  "_IOPMSchedulePowerEvent", referenced from:

1 个答案:

答案 0 :(得分:2)

编译器给你什么投诉?您是否链接到IOKit.framework?如果投诉类似于以下内容:

Undefined symbols:
"_IOPMSchedulePowerEvent", referenced from:
-[iokittestAppDelegate applicationDidFinishLaunching:] in iokittestAppDelegate.o
ld: symbol(s) not found
collect2: ld returned 1 exit status

上述意味着您无法链接到IOKit框架。