当我从EKEvent访问属性BirthdayContactIdentifier时,我总是立即收到BAD_ACCESS错误(甚至无法无效检查)

这是我用来获取的代码

import UIKit
import EventKit
class ViewController: UIViewController {

let eventStore : EKEventStore = EKEventStore()
override func viewDidLoad() {
    super.viewDidLoad()

    eventStore.requestAccessToEntityType(.Event) { (granted, error) in
        if granted == true {
            let startDate = NSDate()
            let endDate = startDate.dateByAddingTimeInterval(7.0*86400.0)

            let events = self.eventStore.eventsMatchingPredicate(self.eventStore.predicateForEventsWithStartDate(startDate, endDate: endDate, calendars: nil))

            for event in events {
                if event.calendar.type == .Birthday {
                    NSLog("\(event.title)")
                    NSLog("\(event.birthdayContactIdentifier)") // BAD_ACCESS
                }
            }
        }
     }
  }
}

最佳答案

我发现错误号22475180 here。尝试BirthdayPersonID。目前从iOS 9开始不推荐使用,但可能会有所不同

关于ios - BirthdayContactIdentifier BAD_ACCESS,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/38198868/

10-08 21:38