title: Detecting contacts in address book that use the app - Swift
body: <p>I'm currently building an app in Swift and I'm having some trouble implementing a feature.</p>
  
  <p>When a user signs up, he enters his phone number which is then stored in the database. Right after the sign up process, I want to display a list of all the user's contacts that already use the app so he can add them, but also the others, so he can invite them via SMS.</p>
  
  <p>On my API, I have an endpoint that can return all the users that match in a list of phone numbers. Right now, I'm trying to do this :</p>
  
  <ul>
  <li>get all the phone numbers in the Address Book</li>
  <li>send them to the API to see if some of these numbers are matching with registered users</li>
  <li>if there's a match, get the list of users back in the app</li>
  <li>update my table view with the data, adding correct button (add or invite) in each cell</li>
  </ul>
  
  <p>My problem is : I don't know how I should link that returned data from the api to my contact list knowing that each contact can have multiple phone numbers. Should I go through my contact list and for each contact, find if one of the phone numbers is contained in the array of users returned by the API ?</p>
  
  <p>I find the process quite heavy. I need to get through the Address book one time to get the phone numbers and display the contacts names on the table view, and then another time to link the data provided by the API to the correct cells.</p>
  
  <p>Is there a better way to handle this ? I'd like to hear your thoughts !</p>