Trong khung Liên hệ mới nhất cho iOS9, cách truy xuất CNContact có địa chỉ email hợp lệ?Swift iOS9 New Contacts Framework - Cách lấy chỉ CNContact có địa chỉ email hợp lệ?
đang hiện tại:
func getContacts() -> [CNContact] {
let contactStore = CNContactStore()
let predicate: NSPredicate = NSPredicate(format: "")
let keysToFetch = [CNContactGivenNameKey, CNContactFamilyNameKey, CNContactEmailAddressesKey]
do {
return try contactStore.unifiedContactsMatchingPredicate(predicate, keysToFetch: keysToFetch)
} catch {
return []
}
}
tuyệt vời, cảm ơn! –
Làm thế nào bạn sẽ sử dụng điều này với một CNContactPickerViewController? Có thể không? Hoặc bạn sẽ phải tạo bộ điều khiển Chế độ xem mới để chọn liên hệ của mình? –
Bạn có thể xem phương thức: predicateForEnablingContact của CNContactPickerViewController – andreacipriani