【问题标题】:Using EventKit to open Calendar.app at a specific date使用 EventKit 在特定日期打开 Calendar.app
【发布时间】:2016-10-06 11:44:20
【问题描述】:

在 macOS/Cocoa 中,有没有办法使用 EventKit 在特定日期/时间打开 Calendar.app?

我使用NSWorkspace.sharedWorkspace().launchAppWithBundleIdentifier("com.apple.iCal", options: .Default, additionalEventParamDescriptor: nil, launchIdentifier: nil)打开应用程序,它可以工作。

在非沙盒环境中,我可以使用 Scripting Bridge 对象并执行以下操作:

let calendarApp = SBApplication(bundleIdentifier: "com.apple.iCal") as! CalendarApplication
if let date = todoItem.properties["icalEventStart"] {
    calendarApp.viewCalendarAt!(date as! NSDate)
}

但启用沙盒后,我找不到方法。 EventKit 有这个用户权限层,所以我认为它可能会代替 SB。

【问题讨论】:

    标签: objective-c swift macos cocoa eventkit


    【解决方案1】:

    我会用 AppleScript 之类的

    tell application "Calendar"
        view calendar at current date
    end tell
    

    您可以通过多种方式在沙盒应用中运行 AppleScript。

    【讨论】:

    • 谢谢马克。这不就是 Scripting Bridge 在幕后所做的吗?
    • 是的,但据我所知,Scripting Bridge 不能用于沙盒。
    猜你喜欢
    • 1970-01-01
    • 2019-06-19
    • 1970-01-01
    • 2013-02-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-09-25
    相关资源
    最近更新 更多