0

I am filtering contact from the ABAddressBook and then showing it using the IOS7 address book picker Ui.

But I am finding the Picker UI to get out of sync...

I use the following code to remove myself:

ABAddressBookRef addressBook = ABAddressBookCreate();
NSArray *people = (__bridge NSArray *) ABAddressBookCopyArrayOfAllPeople(addressBook);

NSMutableArray * recordsToRemoveArray = [[NSMutableArray alloc]init];

/* Here I decide which records we want to remove 
   and add them to the 'recordsToRemoveArray */

/* Finally, we iterate through the array of records to remove, 
   removing them from our copy of the address book: */
for (int l=0; l < recordsToRemoveArray.count; l++) {
    ABRecordRef recToRemoveRef = (__bridge ABRecordRef)([recordsToRemoveArray objectAtIndex:l]);

    ABAddressBookRemoveRecord(addressBook, recToRemoveRef, nil);
}

However, I am finding that the contacts get out of sync with the 'Letter section'

This only happens if I am the only contact in the section.

E.g. Bob Smith is removed from the Letter 'S' section, but the Picker still shows the 'S' Section, but with the next sections contacts in it!

Anyone know how to avoid this? I haven't found a remove section api or a way to force update the ABAddressBook.

DEzra
  • 2,978
  • 5
  • 31
  • 50
  • If I'm not mistaken, it has sometimes happened to me in the Address Book app. – Lior Pollak Oct 21 '13 at 14:20
  • I have now found that if I call ABAddressBookSave(addressBook, NULL); after the remove, the UI sections are correctly displayed. BUT this will have the unwanted effect of actually deleting the address book contact, when I only want to filter it from Picker. – DEzra Oct 21 '13 at 16:06

0 Answers0