EventKit我在做什么错?

时间:2018-07-30 20:36:47

标签: swift macos eventkit

我正在尝试使用EventKit访问macOS提醒,但是当我尝试访问默认日历时,尽管有默认列表集和帐户集,但它显示“在展开包装时意外发现nil”。这适用于iOS,但不适用于macOS。请让我知道我在做什么错。

override func viewDidLoad() {  
    super.viewDidLoad()  

    eventStore = EKEventStore()    
    eventStore.requestAccess(to: .reminder) { (granted, error) in  
        if granted{  
            allReminders = [EKReminder]()  
            let cal = eventStore.calendars(for: .reminder).first  
            let predicate = eventStore.predicateForIncompleteReminders(withDueDateStarting: nil, ending: nil, calendars: [cal!])  

            eventStore.fetchReminders(matching: predicate, completion: { (reminders: [EKReminder]?) -> Void in  
                allReminders = reminders!  
            })  
        } else {  
        }  
    }  

0 个答案:

没有答案