我很难将我的CFRelease()
电话放在下面的代码中。如果我将我的CFRelease()
放在一个括号内,它会抱怨在另一个括号中丢失。
ABMutableMultiValueRef phones = ABRecordCopyValue(person, kABPersonPhoneProperty);
if (phones == nil || ABMultiValueGetCount(phones) == 0) {
CFArrayRef linkedContacts = ABPersonCopyArrayOfAllLinkedPeople(person);
phones = ABMultiValueCreateMutable(kABPersonPhoneProperty);
for (int i = 0; i < CFArrayGetCount(linkedContacts); i++) {
ABRecordRef linkedContact = CFArrayGetValueAtIndex(linkedContacts, i);
ABMultiValueRef linkedPhones = ABRecordCopyValue(linkedContact, kABPersonPhoneProperty);
if (linkedPhones != nil && ABMultiValueGetCount(linkedPhones) > 0) {
for (int j = 0; j < ABMultiValueGetCount(linkedPhones); j++) {
ABMultiValueAddValueAndLabel(phones, ABMultiValueCopyValueAtIndex(linkedPhones, j), NULL, NULL);
}
}
}
if (ABMultiValueGetCount(phones) == 0) {
return NO;
}
}