1
我很难在下面的代码中将CFRelease()
调用放在哪里。如果我将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;
}
}
感谢您指点我在正确的方向:) – 2013-04-20 16:53:23
@PeterWarbo:不客气。我懒得“修复”整个功能,但如有必要,请随时索取更多信息! – 2013-04-20 17:13:33