I'm looking to show contact thumbnails in my app based on email address, similar to what some mail apps do for email conversations. The images will be shown in a tableview.
I've tried searching the address book and getting a thumbnail for each contact, but it is just too slow to use. I've also already tried lazily loading the image, triggered by cellForRowAtIndexPath, and searching in a background thread in order to not block the main thread. Testing with only about 7,000 contacts, this can take around 30 seconds per contact.
Here is a short gist of the general code - https://gist.github.com/eytanbiala/7456bfcd0c55be056720 Obviously this can be optimized to only load all the contacts once, but for the sake of the question this doesn't matter.
Some users may have up to 100,000 contacts on their device, so this is just way too slow.
One suggestion that has come up is to sync the contacts from the iOS Address Book to the app, and save them in Core Data. Of course, this adds possibly unnecessary complexity to the app.
What is the best way to approach this task?