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