Chapter 11. Contacts
The Contacts framework is for those who want to import, show, select, modify, and save contacts on a user’s iOS device. This framework is fully compatible with Swift’s lingo and is very easy to work with. At the heart of the Contacts framework is the
CNContact object, which represents a contact. You get access to the Contacts database using the
Every time you want to access the address book, whether you are trying to create a new contact or fetch an existing one, you need to ensure that you have sufficient access to the address book. You can check your access privileges using the
authorizationStatus(for:) class method of your contact store. This method takes in one parameter of type
CNEntityType. You can pass the value of
Contacts to this method, for instance, to ask for access to the user’s contacts. If you do not have access, you can use the
requestAccess(for:completionHandler:) method of your contact store to request access.
The concept of a partial contact is important enough to cover now as well. A partial contact is a contact whose properties have not all been fetched from the store yet. For instance, perhaps you can fetch only a contact’s first and last name, not her profile photo or email addresses. This is a partial contact. A partial contact’s other information—such as email addresses—that has not been fetched yet can later be fetched from the store using her identifier (part of the
Some of the classes that ...