简体   繁体   中英

birthdayContactIdentifier BAD_ACCESS

When I access the property birthdayContactIdentifier from EKEvent I always instantly get a BAD_ACCESS error (not even able to nil check)

This is the code I am using to fetch

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  
                }  
            }  
        }  
     }   
  }  
} 

I found bug number 22475180 here . Try birthdayPersonID. It is currently deprecated as of iOS 9, but it might work differently

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM