ABMultiValueCopyLabelAtIndex中的CFStringRef无效

时间:2012-07-07 21:20:28

标签: iphone objective-c addressbook cfstring

我从通讯录中收到电话号码。我是这样做的:

ABMultiValueRef arrTelefonos = ABRecordCopyValue(contacto,kABPersonPhoneProperty);
for(int i=0;i<ABMultiValueGetCount(arrTelefonos);i++) {
   CFStringRef labelTelefono = ABMultiValueCopyLabelAtIndex(arrTelefonos,i);
   CFStringRef numeroTelefono = ABMultiValueCopyValueAtIndex(arrTelefonos,i);
   CFStringRef labelTelefonoLoc = ABAddressBookCopyLocalizedLabel(labelTelefono);
   /* Do some stuff */
}

除了一种情况外,一切都还可以:如果有标有特殊字符的手机有联系人(在我的情况下,标签是:“Teléfono”带有“é”,我在做“无效的CFStringRef”时)

CFStringRef labelTelefono = ABMultiValueCopyLabelAtIndex(arrTelefonos,i);

由于CFStringRef不允许特殊字符,是否存在问题?如果这是问题,任何人都知道解决方案吗?

提前谢谢

1 个答案:

答案 0 :(得分:-1)

NSMutableArray *phoneNumbers = [[NSMutableArray alloc] init];

        ABMultiValueRef multiPhones = ABRecordCopyValue(person, kABPersonPhoneProperty);
        for(CFIndex i=0;i<ABMultiValueGetCount(multiPhones);i++) {

            CFStringRef phoneNumberRef = ABMultiValueCopyValueAtIndex(multiPhones, i);
            NSString *phoneNumber = (__bridge NSString *) phoneNumberRef;
            [phoneNumbers addObject:phoneNumber];

            //NSLog(@"All numbers %@", phoneNumbers);

        }