title: How to detect and add missing telephone area codes?
body: <p>If I have a contact in my iPhone address book of the form XXX-YYYY and tap it to dial it then the iPhone dials the number 206-XXX-YYYY (206 is the area code for Seattle, US, which is where the phone doing the dialing and the phone being dialed both are).</p>
  
  <p>I have an app which goes through a user's Contact's app extracting the phone numbers and I would like to be able to detect when an area code is missing like this and to add it in the same was as iOS itself is doing.</p>
  
  <p>Does anybody have any idea how I could do this?</p>
  
  <p>I know the iPhone's phone number, which will be for example AAA-BBB-CCCC, so I could compare AAA-BBB-CCCC with the phone numbers in the address book and if I see a number like XXX-YYYY then I could deduce a) that the area code is missing and b) that the missing area code must be the same as the iPhone's area code and so prepend AAA to XXX-YYYY.</p>
  
  <p>I know that's going to be too simplistic a solution, and might only work in North America.</p>
  
  <p>So how is the iPhone doing it, and is there a scalable solution that will work for all countries?</p>
  
  <p>I'm aware of libPhoneNumber (and an iOS port of it <a href="https://github.com/iziz/libPhoneNumber-iOS" rel="nofollow">https://github.com/iziz/libPhoneNumber-iOS</a>) but looking through its API I can't see anything that will firstly detect if an area code is missing from a phone number. Maybe its there, but the iOS libPhoneNumber port isn't extensively documented.</p>
  
  <p>Anybody faced and solved a similar issue to this?</p>