我希望我的代码为一些联系人添加相同的属性。我在苹果开发者网站上看到了this,但我无法让它发挥作用。如果我的财产属于评论类型或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);
}