My question concerns markup that surrounds some of the default phone number labels in the Person entries of the Contact list on the iPhone.
I have created an iPhone contact list address book entry for a person, "John Smith" with the following phone number entries:
Note that the first five labels are default labels provided by the Contacts application and the last label, "megaphone", is a custom label.
I wrote the following method to retrieve and display the labels and phone numbers for each person in the address book:
-(void)displayPhoneNumbersForAddressBook {
ABAddressBookRef book = ABAddressBookCreate();
CFArrayRef people = ABAddressBookCopyArrayOfAllPeople(book);
ABRecordRef record = CFArrayGetValueAtIndex(people, 0);
ABMultiValueRef multi = ABRecordCopyValue(record, kABPersonPhoneProperty);
NSLog(@"---------" );
NSLog(@"displayPhoneNumbersForAddressBook" );
CFStringRef label, phone;
for (CFIndex i = 0; i < ABMultiValueGetCount(multi); ++i) {
label = ABMultiValueCopyLabelAtIndex(multi, i);
phone = ABMultiValueCopyValueAtIndex(multi, i);
NSLog(@"label: \"%@\" number: \"%@\"", (NSString*)label, (NSString*)phone);
CFRelease(label);
CFRelease(phone);
}
NSLog(@"---------" );
CFRelease(multi);
CFRelease(people);
CFRelease(book);
}
and here is the output for the address book entry that I entered:
2010-03-08 13:24:28.789 test2m[2479:207] ---------
2010-03-08 13:24:28.789 test2m[2479:207] displayPhoneNumbersForAddressBook
2010-03-08 13:24:28.790 test2m[2479:207] label: "_$!<Mobile>!$_" number: "(604) 123-4567"
2010-03-08 13:24:28.790 test2m[2479:207] label: "iPhone" number: "(778) 123-4567"
2010-03-08 13:24:28.791 test2m[2479:207] label: "_$!<Home>!$_" number: "(604) 789-4561"
2010-03-08 13:24:28.791 test2m[2479:207] label: "_$!<Work>!$_" number: "(604) 456-7891"
2010-03-08 13:24:28.792 test2m[2479:207] label: "_$!<Main>!$_" number: "(604) 789-1234"
2010-03-08 13:24:28.792 test2m[2479:207] label: "megaphone" number: "(234) 567-8990"
2010-03-08 13:24:28.793 test2m[2479:207] ---------
What are the markup characters
_$!< and >!$_
surrounding most, save for iPhone, of the default labels for?
Can you point me to where in the "Address Book Programming Guide for iPhone OS" I can find the information?
Thank you for your help.
You can go into the Contacts app, choose a contact, and click on Edit. Then you can click the label next to the number or email of the contact and you will get into Labels. Scrolling down will get you to Add Custom Label. You can add additional labels here or swipe left and delete older labels you don't want to use.
Change a label: Tap the label, then select one in the list, or tap Add Custom Label to create one of your own. Add a birthday, social profile, related name, and more: Tap. next to the item. Allow calls or texts from a contact to override Do Not Disturb: Tap Ringtone or Text Tone, then turn on Emergency Bypass.
By default, your new contacts are saved to your iCloud account, as it is the first account added to your iPhone. To save to Google or another account, follow these steps: Open “Settings” on your iPhone or iPad.
Contacts is a database for your use. Unless you are sharing an account with someone, or unless you hand your phone to someone, no one else can see that information.
I'm running into the same issue. This is what I think so far.
The markup that your seeing indicates to the system that this is a Default label and not a custom label. If you run this code:NSLog(kABOtherLabel);
you'll ge this result:_$!<Other>!$_
So that is the value stored in the kABOtherLabel
constant (of type CFStringRef). I think the reason iPhone
doesn't have the markup around it is becuase it's a 'Custom' label, but it's one originated by Apple instead of the user.
You can give the label any value you like, as evidenced by your megaphone
label above. But notice that if you try and create a phone number (or e-mail address) with the label 'other' without using the kABOtherLabel
constant or it's value _$!<Other>!$_
, the system will think that you're creating a custom label. Like in this example:
ABMultiValueAddValueAndLabel(email, @"[email protected]", @"other", NULL);
And if you go and edit that Address Book entry on the iPhone, it will show up in a separate list of custom labels. (So there will be 2 choices for 'other', one in the defaults and one in the custom labels)
While this hasn't answered your question, I hope it helps.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With