What are the Tags Around Default iPhone Address Book People Phone Number Labels?

安稳与你 提交于 2019-12-05 04:35:44

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, @"nospam@notarealdomain.com", @"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.

This is largely the same in the new CNContact framework that replaced ABAddressBook as the recommended way to handle contacts.

There are six default labels that Apple provides, which are referenced with phone-specific CNLabelledValue constants:

CNLabelPhoneNumberiPhone = "iPhone"
CNLabelPhoneNumberMobile = "_$!<Mobile>!$_"
CNLabelPhoneNumberMain = "_$!<Main>!$_"
CNLabelPhoneNumberHomeFax = "_$!<HomeFAX>!$_"
CNLabelPhoneNumberOtherFax = "_$!<OtherFAX>!$_"
CNLabelPhoneNumberPager = "_$!<Pager>!$_"

The inclusion of _$!< and >!$_ around five of these constants is most likely a marker that the strings can be localised by the operating system, given the availability of the method localizedString(forLabel:). I believe the reason these delimiters do not appear around iPhone is because Apple does not localize iPhone, which is displayed as "iPhone" in all languages.

The sensible behaviour would be to hide these when displaying the string, which occurs using localizedString(forLabel:), continue to store these delimiters with the string if editing the entry, and map any user-created label to these strings where the custom label was equal to the main body of these, i.e., Mobile, Main, Pager, and so on.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!