iOS-ABAddressBook-向现有联系人添加属性
我希望我的代码向某些联系人添加相同的属性。我在苹果开发者网站上看到了,但我无法让它工作。我不介意我的属性是注释类型还是iOS-ABAddressBook-向现有联系人添加属性,ios,abaddressbook,abperson,Ios,Abaddressbook,Abperson,我希望我的代码向某些联系人添加相同的属性。我在苹果开发者网站上看到了,但我无法让它工作。我不介意我的属性是注释类型还是kABPersonInstantMessageProperty类型 我的目标是用旗子标记一些联系人。我有一系列电话号码,我想在联系人中标记这些号码。谁能给我举个例子说明我该怎么做 我的代码是(据我所知,假设将属性“TEST”添加到第一个联系人中): 向我们展示您尝试了什么,以及您遇到了什么错误编辑了问题。 - (void)addPropertyTest { ABMutab
kABPersonInstantMessageProperty
类型
我的目标是用旗子标记一些联系人。我有一系列电话号码,我想在联系人中标记这些号码。谁能给我举个例子说明我该怎么做
我的代码是(据我所知,假设将属性“TEST”添加到第一个联系人中):
向我们展示您尝试了什么,以及您遇到了什么错误编辑了问题。
- (void)addPropertyTest {
ABMutableMultiValueRef multi = ABMultiValueCreateMutable(kABMultiStringPropertyType);
CFErrorRef anError = NULL;
ABMultiValueIdentifier multivalueIdentifier;
bool didAdd, didSet;
// Here, multivalueIdentifier is just for illustration purposes; it isn't
// used later in the listing. Real-world code can use this identifier to
// reference the newly-added value.
didAdd = ABMultiValueAddValueAndLabel(multi, @"TEST",
kABPersonInstantMessageServiceKey, &multivalueIdentifier);
if (!didAdd) {/* Handle error here. */}
ABRecordRef aRecord = (__bridge ABRecordRef)([_allContacts objectAtIndex:0]);
didSet = ABRecordSetValue(aRecord, kABPersonPhoneProperty, multi, &anError);
if (!didSet) {/* Handle error here. */}
CFRelease(multi);
}