title: Phone app prompt works half the time swift
body: <p>Im making an app which imports all contacts stored on a device to the app UITableView
  And when cell is selected the dialler should pop up with a selected phone number.
  However it works half the time</p>
  <pre><code>import UIKit
  import Contacts
  import ContactsUI
  
  struct ContactsArray {
      var name: String
      var familyName: String
      var phoneNumber: String
  }
  
  class ViewController: UIViewController {
      
      var contactsArray = [ContactsArray]()
  
      override func viewDidLoad() {
          super.viewDidLoad()
          
          fetchContacts()
          
          // Some UI setup
      }
      
      func fetchContacts() {
          let store = CNContactStore()
          
          store.requestAccess(for: .contacts) { (granted, err) in
              if let err = err {
                  print(&quot;failed to get access&quot;, err)
                  return
              }
              
              if granted {
                  print(&quot;granted&quot;)
                  
                  let key = [CNContactGivenNameKey, CNContactFamilyNameKey, CNContactPhoneNumbersKey]
                  let request = CNContactFetchRequest(keysToFetch: key as [CNKeyDescriptor])
                  
                  do {
                      var contactsArray = self.contactsArray
                      
                      try store.enumerateContacts(with: request, usingBlock: { (contact, stopPointer) in
                          
                          contactsArray.append(ContactsArray(name: contact.givenName, familyName: contact.familyName, phoneNumber: contact.phoneNumbers.first?.value.stringValue ?? &quot;&quot;))
                          
                      })
                      
                      self.contactsArray = contactsArray
                      
                  } catch let err {
                      print(&quot;failed to enumerate contacts&quot;)
                  }
                  
              } else {
                  print(&quot;grant denied...&quot;)
              }
          }
      }
      
  }
  
  
  extension ViewController: UITableViewDelegate, UITableViewDataSource {
      // Some code here, cell count, cellForItemAt and etc.
      
      func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
          tableView.deselectRow(at: indexPath, animated: true)
          
          let phoneNumber = contactsArray[indexPath.row].phoneNumber
          print(&quot;number: \(contactsArray[indexPath.row].phoneNumber)&quot;) // This prints the correct number
          print(&quot;number phone: \(phoneNumber)&quot;) // This prints the correct number too
          
          // However here, the same phoneNumber prints error
          guard let number = URL(string: &quot;telprompt://\(phoneNumber)&quot;) else {
              print(&quot;error&quot;)
              return
              
          }
          UIApplication.shared.open(number)
          
          
          
      }
  }
  
  </code></pre>
  <p>The thing is, when I select specific contacts like my teacher or coach, it always opens up properly. However when I click other contacts like friend1, friend2 or whatever, it gets into return block.</p>
  <p>I've added some comments to the didSelectRowAt method. Thats where the action is happening. Please help me out, thanks</p>