title: Quickly Parse Phone Numbers of Contact Object in Objective-C
body: <p>I am wondering if there is a more efficient way of identifying which phone numbers in a contact are populated than going through one by one and checking.  Perhaps there are dictionary or array methods of which I am only dimly aware that would be good for working with varying collections of phone numbers for different contacts.</p>
  
  <p>The contact object has strings for phone number and  a lot of varieties, mobile, office, home, fax, main, toll free etc.</p>
  
  <p>The dumb approach that I'm using is along the following lines:</p>
  
  <pre><code>NSString *office = myContact.officetel;
  NSString *home = myContact.hometel;
  NSString *mobile - myContact.mobiletel;
  
  NSMutableArray *phonenums = [@[] mutableCopy]; 
  if (office.length&gt;=1) {
  [phonenums addObject: office];
  etc.
  }
  </code></pre>
  
  <p>When I have assembled this array, I can then count its members to see if there is one or more and so forth.  However, it is a tedious and inefficient approach it seems.</p>
  
  <p>My goal is to be able to quickly identify if there is just one phone number and, if there are say, three out of five, offer up those possibilities to user.</p>
  
  <p>Just wondering if there is a more powerful, efficient approach than the one above.</p>