1

I am writing an app (swift 3) where I would like the user to be able to select any of their address book contacts to perform some actions with them. I have looked at the documentation for it and recognize that I need to use CNContactStore but don't understand much else from it. There are several fetch functions that include withIdentifier but I want them to be able to access any one of their contacts, so I will not know which identifier to use until after they have selected them. So how can i fetch all of their data to allow the user to make their choice?

Nishant Bhindi
  • 2,242
  • 8
  • 21
Runeaway3
  • 1,439
  • 1
  • 17
  • 43
  • " I would prefer to just use the following to wrap the individual functions as opposed to the entire class" But the code you are showing does _not_ wrap an individual function. That's the problem. You don't use `if #available` to mark a function. However, I treat that as a separate question. – matt Aug 17 '17 at 03:05
  • The entire thing was supposed to be a function, my bad. However, nothing changes if I put a function in there. I still get an error – Runeaway3 Aug 17 '17 at 03:07
  • Nvm, I see what you mean – Runeaway3 Aug 17 '17 at 03:08
  • Before you worry about `CNContactStore`, you may first want to present a UI to let the user pick a contact, so you don't write your own contact picking UI. For this, you use the [ContactsUI.framework](https://developer.apple.com/documentation/contactsui). Frankly, I'd suggest starting with WWDC 2015 [Introducing the Contacts Framework](https://developer.apple.com/videos/play/wwdc2015/223/), which talks about both Contacts and ContactsUI frameworks. – Rob Aug 17 '17 at 05:06

0 Answers0