Cocoa 不能';导入系统事件应用程序
请尝试使用此部件代码Cocoa 不能';导入系统事件应用程序,cocoa,Cocoa,请尝试使用此部件代码 -(IBAction)goAway:(id)sender{ SystemEventsApplication *systemEvents = [SBApplication applicationWithBundleIdentifier:@"com.apple.systemevents"]; [systemEvents sleep]; } 但找不到从何处导入SystemEventsApplication,无法导入SystemEvents.h 在此处找到此解决方
-(IBAction)goAway:(id)sender{
SystemEventsApplication *systemEvents = [SBApplication applicationWithBundleIdentifier:@"com.apple.systemevents"];
[systemEvents sleep];
}
但找不到从何处导入SystemEventsApplication,无法导入SystemEvents.h
在此处找到此解决方案要使用脚本桥,您需要从相关应用程序的脚本定义生成头文件。《脚本桥编程指南》的这一部分将介绍以下内容: 在开始为项目编写脚本桥代码之前,应完成以下几个步骤:
sdef /System/Library/CoreServices/System\ Events.app | sdp -fh --basename SystemEvents
这将生成SystemEvents.h
,其中包含SystemEventsApplication
的定义,然后可以将其包含在项目中