存储在地址簿中的所有电话号码都有一个标签,例如:“家庭”、“工作”、“家庭传真”等。我需要更改特定联系人的标签,放置一个名为“ATM”的自定义标签。
我收到此错误消息:
"Assertion failed: (((ABCMultiValue *)multiValue)->flags.isMutable), function ABMultiValueReplaceLabelAtIndex, file /SourceCache/AddressBook_Sim/AddressBook-796.6/ABMultiValue.c, line 118."
这是我的代码,有一条评论我得到了例外:
- (void)displayPerson:(ABRecordRef)person {
NSString* name = (__bridge_transfer NSString*)ABRecordCopyValue(person, kABPersonFirstNameProperty);
self.firstName.text = name;
NSString* phone = nil;
NSString* lbl = nil;
NSString* newLbl = @"ATM";
ABMultiValueRef phoneNumbers = ABRecordCopyValue(person,
kABPersonPhoneProperty);
if (ABMultiValueGetCount(phoneNumbers) > 0) {
phone = (__bridge_transfer NSString*)
ABMultiValueCopyValueAtIndex(phoneNumbers, 0);
lbl = (__bridge_transfer NSString*)
ABMultiValueCopyLabelAtIndex(phoneNumbers, 0);
//*** HERE IS THE PROBLEM ***
ABMultiValueReplaceLabelAtIndex(phoneNumbers, CFSTR("ATM"), 0);
NSLog(@" - %@ (%@)", phone, lbl);
} else {
phone = @"[None]";
lbl = @"[None]";
newLbl = @"[None]";
}
CFRelease(phoneNumbers);
}
如何更改该电话号码的标签?