【问题标题】:Company field when enumerating contacts through CNContactStore通过 CNContactStore 枚举联系人时的公司字段
【发布时间】:2020-09-01 20:45:45
【问题描述】:

我正在使用 CNContactStore 获取一些联系人字段,例如 first name (CNContactGivenNameKey) 和 last name (CNContactFamilyNameKey) 但我不能找到 company 的密钥。

let request = CNContactFetchRequest(keysToFetch: [
  CNContactGivenNameKey as NSString,
  CNContactFamilyNameKey as NSString,
])

request.sortOrder = .familyName

do {
  let store = CNContactStore()
  try store.enumerateContacts(with: request) { contact, stop in
    // ...
  }
} catch {
  print(error)
}

【问题讨论】:

    标签: swift cncontact cncontactstore


    【解决方案1】:

    密钥是CNContactOrganizationNameKey

    混淆来自于联系人应用程序(在所有 iOS、iPadOS 和 macOS 中)使用单词 company 而 key 将其称为 organization,使得通过 Xcode 中的自动完成功能或在 Google 或 Stack Overflow 中搜索时很难找到。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-09-20
      • 2016-09-05
      • 2011-07-31
      • 2010-10-22
      • 1970-01-01
      相关资源
      最近更新 更多