How to get the label value from contacts using phone number || cnlabel get string swift || CNContact get the name label and name

 Solution:

   Below you can find the label and name from the phone number.

      for cont in place.phoneNumbers

        {

          let replaced = cont.value.stringValue.replacingOccurrences(of: "[^0-9+]", with: "", options: NSString.CompareOptions.regularExpression, range:nil)


          if replaced == myphoneNumber

                    {

                      let localizedLabel = CNLabeledValue<NSString>.localizedString(forLabel: cont.label!)

                       let PhoneLabel = localizedLabel

                      break

                              }

                else

                   {

                          continue

                   }


         }


Comments

Popular posts from this blog

Invalid bundle error while upload the app to the app Store

store cgpoint in userdefaults iOS swift