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

标签 objective-c swift macos cocoa eventkit

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

相关文章:

objective-c - UITableView 滚动时中断?

arrays - 如何调用 Swift Array.indexOf?

objective-c - LSUIElement代理应用程序更新核心数据后,如何通知其他应用程序?

c++ - Google Test Discovery在Mac OS X上两次添加并运行了我所有的测试

c++ - qt 5.4/clang:体系结构 x86_64 的 undefined symbol (std::istream::gcount())

objective-c - 生成的自定义托管对象类未构建

iphone - 带圆角的 UIView?

ios - 如何在iOS中获取配对BLE设备?

swift - 我有一个新的 UIViewController 和新类,但我无法在 Xcode 10 中将两者关联起来

json - 使用 SwiftyJSON 解析 JSON 时出现问题