单击此窗口上安装的“继续”按钮后,我找不到关闭主窗口的正确方法。我尝试将此按钮连接到检查器的“ proceedclose”选项。我也尝试在代码中插入以下行:
import Cocoa
class ViewController: NSViewController {
...
@IBAction func Envoi(sender: NSButton) {
self.view.window!.close()
}
}
Run Code Online (Sandbox Code Playgroud)
它们都不起作用,没有任何反应,也没有错误报告。有人可以帮我解决吗?
我正在构建一个 Mac 应用程序,它应该在日历中添加提醒。构建没有错误也没有警告,但当应用程序启动时,我收到以下错误:“提醒失败,错误访问此事件存储未经授权。”
我在网上搜索了在 Mac 上请求访问日历的正确方法,但没有找到任何方法。
我尝试将以下示例从 ios 翻译到 mac,但失败了: https: //github.com/andrewcbancroft/EventTracker/tree/ask-for-permission
这是我的代码:
import Cocoa
import EventKit
@NSApplicationMain
class AppDelegate: NSObject, NSApplicationDelegate, NSTableViewDataSource, NSTableViewDelegate
{
@IBOutlet weak var window: NSWindow!
var eventStore = EKEventStore()
var calendars: [EKCalendar]?
func applicationDidFinishLaunching(_ aNotification: Notification)
{
let reminder = EKReminder(eventStore: self.eventStore)
reminder.title = "Go to the store and buy milk"
reminder.calendar = eventStore.defaultCalendarForNewReminders()
do
{
try eventStore.save(reminder,
commit: true)
} catch let error {
print("Reminder failed with error \(error.localizedDescription)")
}
}
func applicationWillTerminate(_ aNotification: …Run Code Online (Sandbox Code Playgroud)