无法在iOS模拟器中检索联系人的出生日期

时间:2017-06-25 08:23:03

标签: ios iphone swift cncontactstore

我正在尝试从iOS检索联系人详细信息,使用联系人商店我无法使用我的代码检索联系人的出生日期,如下所示

 var toFetch = [CNContactGivenNameKey, CNContactFamilyNameKey, CNContactEmailAddressesKey, CNContactBirthdayKey]

let request = CNContactFetchRequest(keysToFetch: toFetch as [CNKeyDescriptor])
do {
  try self.contatcStore.enumerateContacts(with: request) {
  (contact, stop) in
  if contact.givenName.characters.count == 0 && contact.familyName.characters.count == 0{
  print("empty contact")
  }
  else{
  self.localContacts.append(contact)
  }
  }
  }
  catch {
  print("unable to fetch contacts")
  }

输出打印为: (lldb)po contact

<CNContact: 0x7fc57864a8f0: identifier=177C371E-701D-42F8-A03B-C61CA31627F6, givenName=Kate, familyName=Bell, organizationName=(not fetched), phoneNumbers=(not fetched), emailAddresses=(
    "<CNLabeledValue: 0x608000277e40: identifier=93D6F4AF-5C10-43FC-8405-A8BB02F2F9F7, label=_$!<Work>!$_, value=kate-bell@mac.com>",
    "<CNLabeledValue: 0x608000277e80: identifier=EDDE51A3-7D90-4E3C-8F9B-A60EC5F34498, label=_$!<Work>!$_, value=www.icloud.com>"
), postalAddresses=(not fetched)>

虽然我提取请求没有生日钥匙,如果我错过任何东西,你们可以纠正我吗?

0 个答案:

没有答案