---
title: "#24: Contacts and Contacts UI 👥"
url: https://littlebitesofcocoa.com/24-contacts-and-contacts-ui
author: Jake Marsh
date: 2015-06-25
published: 2015-06-25
topics: ["iOS 9","Contacts"]
description: "Interacting with a user's Contacts database used to be, shall we say, \"less than ideal\". The AddressBook framework was great for it’s time, but it’s a bit..."
---

# #24: Contacts and Contacts UI 👥

By Jake Marsh, June 25, 2015. HTML: https://littlebitesofcocoa.com/24-contacts-and-contacts-ui

Interacting with a user's Contacts database used to be, shall we say, "less than ideal". The **AddressBook** framework was great for it’s time, but it’s a bit past it's prime these days. 

**Contacts** and **Contacts UI** are two new frameworks in **iOS 9** (and **OS X** + **watchOS**) that make integrating Contact data into your app a breeze.

Here's how easy it is to search a user’s contacts and present one for viewing:

``` swift
func presentContactMatchingName(name: String) throws {
    let predicate = CNContact.predicateForContactsMatchingName(name)
    let keysToFetch = [CNContactGivenNameKey, CNContactFamilyNameKey]
    let store = CNContactStore()

    let contacts = try store.unifiedContactsMatchingPredicate(
        predicate, 
        keysToFetch: keysToFetch
    )

    if let firstContact = contacts.first {
        let viewController = CNContactViewController(forContact: firstContact)
        viewController.contactStore = self.store

        presentViewController(viewController, animated: true, completion: nil)
    }
}
```

Also, Apple has officially deprecated **AddressBook** and **AddressBookUI** so now's the time to  make the switch!

<img src="https://media.littlebitesofcocoa.com/bite-assets/024-contacts-contacts-ui-example.png" style="max-width: 364px;" />
