这就是我现在做事的方式:
-(void)vPopulateContact
{
NSArray * arPeople = (__bridge_transfer NSArray*)(ABAddressBookCopyArrayOfAllPeople( self.addressBook));
NSMutableArray * arPeople1 = [NSMutableArray array];
for (id somePeople in arPeople) {
ABRecordRef ABPerson= (__bridge ABRecordRef)somePeople; //do not transfer ownership
RCABRecordRef * abRRWrapper = [[RCABRecordRef alloc]init];
abRRWrapper.abRecordRef=ABPerson;
[arPeople1 addObject:abRRWrapper];
}
NSArray * arPeople2=[arPeople1 sortedArrayUsingComparator:^NSComparisonResult(id obj1, id obj2) {
RCABRecordRef * abr1 = (RCABRecordRef*) obj1;
NSDate * date1=abr1.dDatedAdded;
RCABRecordRef * abr2 = (RCABRecordRef*) obj2;
NSDate * date2=abr2.dDatedAdded;
return [date2 compare:date1];
}];
self.allMyContacts=[arPeople2 subarrayWithRange:NSMakeRange(0, MIN(200,arPeople2.count))].mutableCopy;
[self.tableView reloadData];
}
将整个通讯簿复制到 nsarray 会占用内存。所以我想要一些没有它的东西。
假设我想找到第五个人或类似的东西。我该怎么做?
我应该只复制该人的ID,然后根据ID查找通讯录吗?