gpt4 book ai didi

objective-c - 使用 EventKit 在特定日期打开 Calendar.app

转载 作者:行者123 更新时间:2023-11-30 13:01:06 25 4
gpt4 key购买 nike

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

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

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

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

但是启用沙箱后,我找不到方法。 EventKit 有这个用户权限层,所以我认为它可能是替代 SB 的候选者。

最佳答案

我会用像这样的AppleScript来做到这一点

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

有多种方法可以让您在沙盒应用程序中运行 AppleScript。

关于objective-c - 使用 EventKit 在特定日期打开 Calendar.app,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39895119/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com