0
當我訪問屬性birthdayContactIdentifier從EKEvent我總是立刻得到BAD_ACCESS錯誤(甚至不能夠零檢查)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
}
}
}
}
}
}
我也發現一個較早的,蘋果沒有給任何解決方案,不幸的是。我會嘗試birthdayPersonID,儘管它可能不會與Contacts框架兼容。但我會盡力回報。 – Guus
剛剛嘗試過與birthdayPersonID,不會給出任何錯誤,但標識符是不同的,所以它不會獲取正確的聯繫人。 – Guus
如果birthdayContactIdentifier錯誤,您如何驗證它不同? (想知道是否有線索) – Feldur