Appleの開発者向けドキュメントで次のコードを見つけましたが、この機能を正しく呼び出す方法を理解できません。どんな指導にも本当に感謝します。swiftを使用してiOSグループに所属する連絡先を一覧表示する方法
func fetchContactsInGroup(with identifier: String, completion: @escaping (_ contacts: [CNContact]) -> Void) {
var result = [CNContact]()
// Fetch only the full name of a person or organization.
let request = CNContactFetchRequest(keysToFetch: [CNContactFormatter.descriptorForRequiredKeys(for: .fullName)])
// Predicate to fetch all contacts that are members of the specified group.
request.predicate = CNContact.predicateForContactsInGroup(withIdentifier: identifier)
contactStoreQueue.async {
do {
try self.store.enumerateContacts(with: request, usingBlock: {(contact, status) -> Void in
// Add each retured contact to result.
result.append(contact)
})
} catch let error as NSError {
print("Error \(error.localizedDescription)")
}
DispatchQueue.main.async {
completion(result)
}
}
}
どの部分が正確に手に入らないのですか? – Losiowaty
func fetchContactsInGroupを呼び出すための構文 - 完了:ビットが私の問題 – Jeremy