0

I try to parse a vcf-file. I use CNContact for this. That works quite well, but with the phonenumbers i have a problem.

With CNLabeledValue<CNPhoneNumber*>* I get the label (e. g. "home") and the phonenumber in the value.

Excerpt from the vCard:

TEL;TYPE=home:1234567890

But if the number is tagged with a "pref" i can't get this tag for the phonenumber.

Excerpt from the vCard:

TEL;TYPE=home,pref:0987654321

Is there anyway to find out, which numbers are the preferred numbers?

I use following code:

for (CNLabeledValue<CNPhoneNumber*>* number in cnContact.phoneNumbers) {
 NSString *label = number.label;
 NSString *number = ((CNPhoneNumber*)number).stringValue;

  //Do some work with label and number
}
  • There's no such concept as a "preferred" phone number with `CNContact`. Even using the Contacts app you will not see any way to make a phone number the preferred number. What it is that you are trying to do with the preferred number in the vCard file? – HangarRash Jan 13 '23 at 22:09
  • You can have multiple numbers, all with "work"-tag. One of them is the preferred number. If you add a Contact from vCard, which contains a preferred number, to the Contacts app you won't see it, but if you export it again, the tag "pref" is saved. – kommerzpunk Jan 16 '23 at 13:06

0 Answers0