Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios ABPerson:如何获得person';s家庭和工作电话(不是传真电话)_Ios_Objective C_Contacts_Abperson - Fatal编程技术网

Ios ABPerson:如何获得person';s家庭和工作电话(不是传真电话)

Ios ABPerson:如何获得person';s家庭和工作电话(不是传真电话),ios,objective-c,contacts,abperson,Ios,Objective C,Contacts,Abperson,我想知道是否有可能提取联系人的家庭电话号码和工作电话号码,而不是他们的家庭传真或工作传真。若否,为何这是一项限制 参考仅提及以下常量: const ABPropertyID kABPersonPhoneProperty; const CFStringRef kABPersonPhoneMobileLabel; const CFStringRef kABPersonPhoneIPhoneLabel; const CFStringRef kABPersonPhoneMainLabel;

我想知道是否有可能提取联系人的家庭电话号码和工作电话号码,而不是他们的家庭传真或工作传真。若否,为何这是一项限制

参考仅提及以下常量:

const ABPropertyID kABPersonPhoneProperty;  
const CFStringRef kABPersonPhoneMobileLabel;  
const CFStringRef kABPersonPhoneIPhoneLabel;  
const CFStringRef kABPersonPhoneMainLabel;  
const CFStringRef kABPersonPhoneHomeFAXLabel;  
const CFStringRef kABPersonPhoneWorkFAXLabel;  
const CFStringRef kABPersonPhoneOtherFAXLabel;  
const CFStringRef kABPersonPhonePagerLabel;
但是如果你用你的iPhone,你会注意到还有更多的标签(更不用说定制的了)。我如何挑选它们?

//contactData是ABRecordRef
//contactData is ABRecordRef
ABMultiValueRef phones = ABRecordCopyValue(contactData, kABPersonPhoneProperty);

for (CFIndex i=0; i < ABMultiValueGetCount(phones); i++) 
{
    NSString* phoneLabel = (NSString*) ABMultiValueCopyLabelAtIndex(phones, i);
    NSString* phoneNumber = (NSString*) ABMultiValueCopyValueAtIndex(phones, i);

    //for example
    if([phoneLabel isEqualToString:(NSString *)kABPersonPhoneMobileLabel])
    {
        //under phoneNumber you have a kABPersonPhoneMobileLabel value
    }
    .. add other standard labels
    else //custom label
    {

    }

    [phoneNumber release];
    [phoneLabel release];
}

CFRelease(phones);
ABMultiValueRef phones=ABRecordCopyValue(contactData,KabPersonPhone属性); 对于(CFIndex i=0;i
kABHomeLabelkABWorkLabel

if (CFStringCompare(phoneLabelRef, kABHomeLabel, 0) == kCFCompareEqualTo) {
        homePhone = (__bridge NSString *)phoneNumberRef;
} else if (CFStringCompare(phoneLabelRef, kABWorkLabel, 0) == kCFCompareEqualTo) {
        officePhone = (__bridge NSString *)phoneNumberRef;
}

请参阅本精彩教程:

谢谢,但我已经有了类似的代码。我的问题是关于其他的。嗯,关于你要问的是什么?:)对于自定义标签,您只有“phoneLabel”不同的值。请选择一个更有用的值。我仍然不明白,为什么我们能为一些手机提供更直接的方式(康斯特的上图),而不是为工作或家庭手机。必须依赖(参考文献中未提及的)字符串比较是很奇怪的,但它显然解决了我的问题。