获取iPhone联系人电话号码类型

时间:2010-02-25 10:37:20

标签: ios iphone objective-c

我可以通过以下代码获取任何联系电话

NSLog(@"%@",ABMultiValueCopyValueAtIndex(ABRecordCopyValue(ref,kABPersonPhoneProperty) ,0));
        NSLog(@"%@",ABMultiValueCopyValueAtIndex(ABRecordCopyValue(ref,kABPersonPhoneProperty) ,1));
        NSLog(@"%@",ABMultiValueCopyValueAtIndex(ABRecordCopyValue(ref,kABPersonPhoneProperty) ,2));
        NSLog(@"%@",ABMultiValueCopyValueAtIndex(ABRecordCopyValue(ref,kABPersonPhoneProperty) ,3));
        NSLog(@"%@",ABMultiValueCopyValueAtIndex(ABRecordCopyValue(ref,kABPersonPhoneProperty) ,4));

但是从上面的代码我不知道哪个电话号码与哪个电话号码相关(对于移动电话,家庭电话,主电话,iPhone等)。

请建议如何识别任何数字的类型?

2 个答案:

答案 0 :(得分:7)

尝试 ABMultiValueCopyLabelAtIndex ,这会为您提供电话号码的类型

答案 1 :(得分:1)

 ABMultiValueRef phoneProperty = ABRecordCopyValue(person,kABPersonPhoneProperty); 

for(int i=0;i<[array count];i++)
{
  NSString* phoneLabel = (NSString*) ABAddressBookCopyLocalizedLabel(ABMultiValueCopyValueAtIndex(phoneProperty,i)
  NSLog(@"%@",phoneLabel);
}