ABMultiValueRef phonesRef = ABRecordCopyValue(person, kABPersonPhoneProperty);
for (int i=0; i < ABMultiValueGetCount(phonesRef); i++)
{
CFStringRef currentPhoneLabel = ABMultiValueCopyLabelAtIndex(phonesRef, i);
CFStringRef currentPhoneValue = ABMultiValueCopyValueAtIndex(phonesRef, i);
if (currentPhoneLabel != nil && currentPhoneValue != nil)
{
if (CFStringCompare(currentPhoneLabel, kABPersonPhoneMobileLabel, 0) == kCFCompareEqualTo)
{
[contactInfoDict setObject:(__bridge NSString *)currentPhoneValue forKey:@"workNumber"];
}
if (CFStringCompare(currentPhoneLabel, kABHomeLabel, 0) == kCFCompareEqualTo)
{
[contactInfoDict setObject:(__bridge NSString *)currentPhoneValue forKey:@"homeNumber"];
}
}
else if (currentPhoneValue != nil && currentPhoneLabel == nil)
{
[contactInfoDict setObject:(__bridge NSString *)currentPhoneValue forKey:@"workNumber"];
}
CFRelease(currentPhoneLabel);
CFRelease(currentPhoneValue);
}
CFRelease(phonesRef);
这是我将联系电话导入我的 ios 应用程序的代码,但是当 currentPhoneLabel 为 CFRelease(currentPhoneLabel) 的 nil xocde 时。我不知道为什么会这样。任何帮助将是非常可观的。
谢谢