Cómo search numbers de teléfono personalizados en la libreta de direcciones rápida

Estoy tratando de search el número de teléfono de label personalizado utilizando la libreta de direcciones (swift).

He intentado con la propiedad kABOtherLabel pero no obtuve el resultado deseado.

Me gustaría saber si hay alguna forma de get properties personalizadas de tags ..?

Aquí estoy compartiendo lo que estoy haciendo actualmente.

Gracias por adelantado.

//phone var phones : ABMultiValueRef = ABRecordCopyValue(contactRef,kABPersonPhoneProperty).takeUnretainedValue() as ABMultiValueRef for(var numberIndex : CFIndex = 0; numberIndex < ABMultiValueGetCount(phones); numberIndex++) { // Number in contact details of current index let phoneUnmaganed = ABMultiValueCopyValueAtIndex(phones, numberIndex) let phoneNumber : NSString = phoneUnmaganed.takeUnretainedValue() as! NSString // Label of Phone Number let locLabel : CFStringRef = (ABMultiValueCopyLabelAtIndex(phones, numberIndex) != nil) ? ABMultiValueCopyLabelAtIndex(phones, numberIndex).takeUnretainedValue() as CFStringRef : "" //check for home if (String(locLabel) == String(kABHomeLabel)) { contact.sUserTelHome = phoneNumber as String contact.sUserTelHomeTrim = contact.sUserTelHome?.trimmedContactNumber() } //check for work else if (String(locLabel) == String(kABWorkLabel)) { contact.sUserTelWork = phoneNumber as String contact.sUserTelWorkTrim = contact.sUserTelWork?.trimmedContactNumber() } //check for mobile else if (String(locLabel) == String(kABPersonPhoneMobileLabel)) { contact.sUserTelMobile = phoneNumber as String contact.sUserTelMobileTrim = contact.sUserTelMobile?.trimmedContactNumber() } else if(String(locLabel) == String(kABOtherLabel)){ } } 

 let customLabel = String (stringInterpolationSegment: ABAddressBookCopyLocalizedLabel(locLabel)) 

Esto imprimirá la label del número de teléfono. Creo que esto es lo que buscas. Para más detalles, visita aquí . Encuentre el código completo a continuación.

EDITAR

 let status = ABAddressBookGetAuthorizationStatus() if status == .Denied || status == .Restricted { // user previously denied, to tell them to fix that in settings return } // open it var error: Unmanaged<CFError>? let addressBook: ABAddressBook? = ABAddressBookCreateWithOptions(nil, &error)?.takeRetainedValue() if addressBook == nil { println(error?.takeRetainedValue()) return } // request permission to use it ABAddressBookRequestAccessWithCompletion(addressBook) { granted, error in if !granted { // warn the user that because they just denied permission, this functionality won't work // also let them know that they have to fix this in settings return } if let people = ABAddressBookCopyArrayOfAllPeople(addressBook)?.takeRetainedValue() as? NSArray { // now do something with the array of people for record:ABRecordRef in people { var phones : ABMultiValueRef = ABRecordCopyValue(record,kABPersonPhoneProperty).takeUnretainedValue() as ABMultiValueRef for(var numberIndex : CFIndex = 0; numberIndex < ABMultiValueGetCount(phones); numberIndex++) { let phoneUnmaganed = ABMultiValueCopyValueAtIndex(phones, numberIndex) let phoneNumber : NSString = phoneUnmaganed.takeUnretainedValue() as! NSString let locLabel : CFStringRef = (ABMultiValueCopyLabelAtIndex(phones, numberIndex) != nil) ? ABMultiValueCopyLabelAtIndex(phones, numberIndex).takeUnretainedValue() as CFStringRef : "" var cfStr:CFTypeRef = locLabel var nsTypeString = cfStr as! NSString var swiftString:String = nsTypeString as String let customLabel = String (stringInterpolationSegment: ABAddressBookCopyLocalizedLabel(locLabel)) println("Name :-\(swiftString) NO :-\(phoneNumber)" ) } } } } 

Salida

 Name :-_$!<Mobile>!$_ NO :-8592-841222 Name :-CUSTOMLABEL NO :-111 Name :-_$!<Home>!$_ NO :-45445 

La primera es mi label personalizada,

Tenga en count que la label pnetworkingeterminada siempre comienza con _$!< Caracteres.