我正试图通过swift从地址簿中获取人们的生日。
let ab = ABAddressBook.sharedAddressBook()
var birthday: CFDateRef?
for person in ab.people() {
birthday = ABRecordCopyValue(person, kABBirthdayProperty)
...
但是我在xcode中遇到以下错误:
AnyObject'无法转换为ABRecordRef
ABRecordCopyValue
期望ABRecordRef
对象作为第一个参数,但人类的类型为AnyObject
。
它也不适用于person as ABRecordRef
答案 0 :(得分:1)
ABRecordRef
与Swift中的ABRecord
相同。您应该能够使用ABRecord
类中的更简单的API:
for person in ab.people() as [ABPerson] {
person.valueForProperty(kABBirthdayProperty)...
}