title: Contact Framework phone array
body: <p>I have a class "Contact" which manages personal information of some people. Now i want to save some of that information using the Contact Framework introduced since iOS 9. </p>
  
  <p>My Contact class has a </p>
  
  <ul>
  <li>Home number (huisnummer in Dutch)</li>
  <li>Mobile number (mobiel in Dutch)</li>
  </ul>
  
  <p>Because some of the contacts have no Home number and some of the contacts have no mobile number it is hard for me to create the array:</p>
  
  <pre><code>// cnContact is an object of the Contact Framework class
  // contact is an object of my Contact class
  
  if let huisnummer = contact.huisnummer  {
      if let mobiel = contact.nummer {
          cnContact.phoneNumbers = [CNLabeledValue(label: CNLabelPhoneNumberMain, value: CNPhoneNumber(stringValue: huisnummer)),CNLabeledValue(label: CNLabelPhoneNumberMobile, value: CNPhoneNumber(stringValue: mobiel))]
      } else {
          [CNLabeledValue(label: CNLabelPhoneNumberMain, value: CNPhoneNumber(stringValue: huisnummer))]
      }
  } else {
      if let mobiel = contact.nummer {
          cnContact.phoneNumbers = [CNLabeledValue(label: CNLabelPhoneNumberMobile, value: CNPhoneNumber(stringValue: mobiel))]
      }
  }
  </code></pre>
  
  <p>I have to keep checking using swifts conditionals if said number exists. But i thought since this is an inefficient way of saving those contacts that there must be a more efficient way to save this. </p>
  
  <p>How can you create the cnContact's phone numbers in a more efficient way?</p>