How to sort contacts using Contacts with Swift

后端 未结 2 1245
失恋的感觉
失恋的感觉 2021-01-12 01:53

I\'ve read official apple documentation about sorting contacts, although I am not sure how to implement it. So, here is fetch request:

let fetchRequest = CNC         


        
2条回答
  •  心在旅途
    2021-01-12 02:29

    If you are using SwiftyContacts, you can pass in the sort option in the fetchContacts(..) request, see below:

    import SwiftyContacts
    
    fetchContacts(ContactsSortorder: .givenName) { (result) in
        switch result {
        case .success(let contacts):
            print(contacts)
        case .failure(let error):
            print(error)
        }
    }
    

提交回复
热议问题