在 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/