0
我嘗試在Calendar.app中顯示一個元素,以便日曆被激活並且相應的事件被突出顯示。我知道該怎麼做,但一旦沙盒是,我只是得到發送AppleEvent失敗並顯示沙箱
Calendar got an error: A privilege violation occurred.
我的代碼簡單說就是(甚至沒有試圖表明一個事件,但只是閱讀一個日曆):
import Cocoa
@NSApplicationMain
class AppDelegate: NSObject, NSApplicationDelegate {
func applicationDidFinishLaunching(aNotification: NSNotification) {
let source = "tell application \"iCal\"\n set theCalendar to first calendar whose name = \"test\"\nend tell"
let scriptObject = NSAppleScript(source: source)
var errorDict: NSDictionary? = nil
_ = scriptObject!.executeAndReturnError(&errorDict)
print (errorDict)
}
}
而且我應享權利看起來像:
<dict>
<key>com.apple.security.app-sandbox</key>
<true/>
<key>com.apple.security.scripting-targets</key>
<dict>
<key>com.apple.ical</key>
<array>
<string>com.apple.ical.read</string>
</array>
</dict>
</dict>
我也嘗試過使用腳本橋,但仍失敗(以較少的信息,但可能由於同樣的原因)。
哇。我做了一個快速測試,但只用我的簡化例子,這似乎是竅門。我現在就嘗試使用完整版本。 –
非常酷。特別是蘋果所謂的「支持」並沒有指出我的方向,但讓我忍飢挨餓3年多的支持請求。非常感謝你!! –