其實(shí)還是 CFTypeRef 類型肚医,添加類似多個手機(jī)號的多信息;依舊使用ABRecord 類添加
- 創(chuàng)建
ABMutableMultiValueRef muRef = ABMultiValueCreateMutable(kABStringPropertyType);
// ABMutableMultiValueRef muRefCopy = ABMultiValueCreateMutableCopy(phones);
- 操作
if (ABMultiValueAddValueAndLabel(muRef, @"13456990987", (__bridge CFStringRef)@"測試標(biāo)題", NULL)) {
NSLog(@"添加");
}
if (ABMultiValueInsertValueAndLabelAtIndex(muRef, @"13456990987", (__bridge CFStringRef)@"測試標(biāo)題", 0, NULL)) {
NSLog(@"指定位置添加");
}
if (ABMultiValueRemoveValueAndLabelAtIndex(muRef, 0)) {
NSLog(@"指定位置移除");
}
if (ABMultiValueReplaceValueAtIndex(muRef, @"13456990987", 0)) {
NSLog(@"指定位置,替換內(nèi)容");
}
if (ABMultiValueReplaceLabelAtIndex(muRef, (__bridge CFStringRef)@"測試標(biāo)題啊啊啊", 0)) {
NSLog(@"指定位置,替換標(biāo)題");
}
// 這個是 ABRecord 類的 基礎(chǔ)添加信息
if (ABRecordSetValue(person, kABPersonPhoneProperty, muRef, NULL)) {
NSLog(@"修改信息");
};
- 獲取
// 復(fù)制
ABMultiValueRef phones = ABRecordCopyValue(person, kABPersonPhoneProperty);
// 屬性類型
ABPropertyType pType = ABMultiValueGetPropertyType(phones);
// 數(shù)據(jù)條數(shù)(例如:聯(lián)系號碼條數(shù))
CFIndex count = ABMultiValueGetCount(phones);
// 取所有值 ()
CFArrayRef array = ABMultiValueCopyArrayOfAllValues(phones);
// 取某條值(187-6711-xxxx)
CFTypeRef value = ABMultiValueCopyValueAtIndex(phones, 0);
// 值的 標(biāo)題(浙江 杭州 移動)
CFStringRef str = ABMultiValueCopyLabelAtIndex(phones, 0);
// 某位置的id
ABMultiValueIdentifier idindex = ABMultiValueGetIdentifierAtIndex(phones, 0);
// 某id 的位置
CFIndex idValue = ABMultiValueGetIndexForIdentifier(phones, idindex);
// 查找 某個值的index -1 不存在
CFIndex indexOfValue = ABMultiValueGetFirstIndexOfValue(phones, @"123");
1
AddressBook 的其他API
#include <AddressBook/ABGroup.h>
#include <AddressBook/ABSource.h>
這兩個 還是沒搞清楚 搞什么玩意,好像也沒怎么用到;峦耘;
1