1
私はこのメソッドを構造化できないので、プロジェクトを解析するときに文句を言うことはありません。CFReleaseを呼び出す際にヌルポインタ引数
私は人のオブジェクトをどのように解放するのか不満です。
- (NSArray *)getAllContacts {
NSMutableArray *result = [NSMutableArray array];
ABAddressBookRef addressBook = ABAddressBookCreate();
CFArrayRef people = ABAddressBookCopyArrayOfAllPeople(addressBook);
CFRelease(addressBook);
NSArray *peopleArray = (NSArray *)people;
// Return if there are no contacts in the address book
if (peopleArray && peopleArray.count > 0) {
for (int i = 0; i <= peopleArray.count -1; i++) {
ABRecordRef person = [peopleArray objectAtIndex:i];
ABRecordID sourceID = ABRecordGetRecordID(person);
TableViewControllerItem *item = [AddressBookModel createTableViewControllerItemFromABRecordID:[NSString stringWithFormat:@"%i", sourceID]];
[result addObject:item];
}
CFRelease(people); //If I put the release here I get a potential leak of people
}
CFRelease(people); //If I put the release here I get a null pointer argument in call to CFRelease
return [NSArray arrayWithArray:result];
}