Im trying to find a phone number in the address book from my app and I was surprised not to find it. The thing is that I've printed all the numbers of my address book in the console accessed by my app and strangely some of the contacts are missing, I was comparing the output with my address book, it's only few, but still.
This is how Im accesing the AddressBook:
ABAddressBookRef addressBook = ABAddressBookCreate();
NSArray *people = (NSArray *) ABAddressBookCopyArrayOfAllPeople(addressBook);
BOOL found = NO;
NSString *name;
int i = 0;
while (!found) {//Here I print all the contact info, name and phone number
ABRecordRef person = (ABRecordRef)[people objectAtIndex:i];
ABMultiValueRef multi = ABRecordCopyValue(person, kABPersonPhoneProperty);
NSLog(@"el telf: %@ y nombre %@",tempPhone2, [NSString stringWithFormat:@"%@ %@",ABRecordCopyValue(person, kABPersonFirstNameProperty) ? (NSString *)ABRecordCopyValue(person, kABPersonFirstNameProperty) : @"",ABRecordCopyValue(person, kABPersonLastNameProperty) ? (NSString *)ABRecordCopyValue(person, kABPersonLastNameProperty) : @""]);
if([[key objectForKey:@"phone"] isEqualToString:tempPhone2]){
found = YES;
}
}
Any idea why Im not accesing all the contacts in my Address Book?
[EDIT]
Weirdest thing is that when I use ABPeoplePickerNavigationController
those missing contacts appear.