0

我希望我的代码为某些联系人添加相同的属性。我在苹果开发者网站上看到了这个 ,但我无法让它工作。我不介意我的财产是评论类型还是评论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);
}
4

0 回答 0