是否仅从通讯录中获取移动部分记录(不来自iphone、家庭标签等)?

是否仅从通讯录中获取移动部分记录(不来自iphone、家庭标签等)?,iphone,ios,ios5,ios6,ios4,Iphone,Ios,Ios5,Ios6,Ios4,如何在ios中仅从通讯簿获取移动部分记录 我只想向数组中添加一条从移动节记录中提取的记录 我该怎么做呢。我正在得到所有的电话记录。但我只需要移动部分的记录 NSArray *allPeople = (NSArray *)ABAddressBookCopyArrayOfAllPeople(myAddressBook); NSLog(@"allpeople%@", allPeople); for (id record in allPeople) { CFTypeRef phonePrope

如何在ios中仅从通讯簿获取移动部分记录

我只想向数组中添加一条从移动节记录中提取的记录

我该怎么做呢。我正在得到所有的电话记录。但我只需要移动部分的记录

NSArray *allPeople = (NSArray *)ABAddressBookCopyArrayOfAllPeople(myAddressBook);
NSLog(@"allpeople%@", allPeople);

for (id record in allPeople) {
    CFTypeRef phoneProperty = ABRecordCopyValue((ABRecordRef)record, kABPersonPhoneProperty);
    NSArray *phones = (NSArray *)ABMultiValueCopyArrayOfAllValues(phoneProperty);

    NSLog(@"phones %@",phones);

    CFRelease(phoneProperty);
    NSMutableDictionary *newRecord = [[NSMutableDictionary alloc] init];
    NSMutableString *newPhone = [[NSMutableString alloc] init];

    for (NSString *phone in phones) {
        if(![newPhone isEqualToString:@""])
            [newPhone appendString:@", "];
        [newPhone appendString:phone];
    }

你可以试试这样的

ABMultiValueRef phoneNumbers = ABRecordCopyValue(abPerson, kABPersonPhoneProperty);
    if (phoneNumbers) {
        CFIndex numberOfPhoneNumbers = ABMultiValueGetCount(phoneNumbers);
        for (CFIndex i = 0; i < numberOfPhoneNumbers; i++) {
            NSString *phone = (__bridge_transfer NSString *)ABMultiValueCopyValueAtIndex(phoneNumbers, i);
            CFStringRef label = ABMultiValueCopyLabelAtIndex(phoneNumbers, i);
            if (label) {
                if (CFEqual(label, kABPersonPhoneMobileLabel)) {
                    primaryPhoneText.text = phone;
                } else {
                }
                CFRelease(label);
                [allPhones addObject:phone]; // allPhones is an array here.
            }
        }
        CFRelease(phoneNumbers);
    }
ABMultiValueRef phoneNumbers=ABRecordCopyValue(abPerson,kabbersonphoneproperty);
if(电话号码){
CFIndex numberOfPhoneNumbers=ab多值getcount(phoneNumbers);
for(CFIndex i=0;i
希望这能帮到你


享受编码的乐趣。

你想从通讯簿中获取手机号码吗?@popeye是的,只有地址簿中的手机号码,那么你为什么不想使用(abPerson,KabbersonPhoneMobileLabel)?@popeye CFTypeRef phoneProperty=ABRecordCopyValue((ABRecordRef)record,KabbersonPhoneMobileLabel);是这样吗?你看到我的答案了吗?请检查是否为您工作?