Alterplay / APAddressBook

Easy access to iOS address book
MIT License
1.38k stars 193 forks source link

Adding New Contacts Don't Appear In List #171

Closed anthonysaltarelli closed 6 years ago

anthonysaltarelli commented 6 years ago

Running APAddressBook with swift 4, using the example code. However, when I add new contacts, they do not appear to be returned. When I modify or delete contacts, those changes are made, however.

I have looked into past issues and tried to fix the problem, but none of the solutions have fixed this issue.

How should I proceed?

belkevich commented 6 years ago

Hi, try this 1) Add breakpoint to this line 2) Add new contact

Does breakpoint fire?

anthonysaltarelli commented 6 years ago

I determined the problem. It was only fetching contacts that had phone numbers attached. I changed the line to check for names instead of phones:

addressBook.filterBlock = { (contact: APContact) -> Bool in if let names = contact.name?.firstName { return names.count > 0 } return false }

Which fixed the problem.