Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/23.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Objective c CGEventCreateKeyboardEvent和沙盒_Objective C_Xcode_Macos_Cocoa - Fatal编程技术网

Objective c CGEventCreateKeyboardEvent和沙盒

Objective c CGEventCreateKeyboardEvent和沙盒,objective-c,xcode,macos,cocoa,Objective C,Xcode,Macos,Cocoa,我正在尝试使用这段代码在Mac OS X的沙盒应用程序中向finder发送击键: CGEventRef a = CGEventCreateKeyboardEvent(NULL, keycode, true); CGEventSetFlags(a, kCGEventFlagMaskControl); CGEventPost(kCGHIDEventTap, a); CFRelease(a); 它在非sanboxed环境中工作,但在沙盒环境中不工作,如果我使用此权限:

我正在尝试使用这段代码在Mac OS X的沙盒应用程序中向finder发送击键:

    CGEventRef a = CGEventCreateKeyboardEvent(NULL, keycode, true);
    CGEventSetFlags(a, kCGEventFlagMaskControl);
    CGEventPost(kCGHIDEventTap, a);
    CFRelease(a);
它在非sanboxed环境中工作,但在沙盒环境中不工作,如果我使用此权限:

  <?xml version="1.0" encoding="UTF-8"?>
  <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
  <plist version="1.0">
     <dict>
       <key>com.apple.security.app-sandbox</key>
       <true/>
       <key>com.apple.security.temporary-exception.apple-events</key>
       <array>
       <string>com.apple.systemevents</string>
       </array>
     </dict>
  </plist>

com.apple.security.app-sandbox
com.apple.security.temporary-exception.apple-events
com.apple.systemevents
我发现有人建议改用Apple脚本,它可以工作,但速度很慢,不适合我的需要

有机会吗