I am currently working on a chat application where I need to keep a copy of cncontact store list to match the names and details of the recipients in the app. I am having a hard time when the user is having a very large addressbook. I am running this task on a background thread but it sometimes slows the application and there are times where the recent updates on addressbook is not reflected within the app.
What is the approach when working with a large addressbook list and how should I go ahead with maintaining it? Should I store it all in ManagedContext and recheck it every time the app opens since notifications from Apple when an update happens, does not get reflected in the app at all times? Just wondering how big chats application out there go ahead with having a coup of the list without blocking the UI and it is always up to date. Any help would be much appreciated.
Don't you need this list only when the user opens the contact list or wants to write a new message? You can use techniques like
CNContact.predicateForContacts(matchingName: "Appleseed")
let keysToFetch = [CNContactGivenNameKey, CNContactFamilyNameKey] as [CNKeyDescriptor]
Fetching contacts with partial data only
You can read more about that in the official docs