---
title: "Contacts bites - Little Bites of Cocoa"
description: "Little Bites of Cocoa about Contacts: short tips and techniques for iOS and Mac development, each a brief explanation of one concept, technique or tool."
url: "https://littlebitesofcocoa.com/topics/39-contacts"
author: "Jake Marsh"
---
# Bites about: [Contacts](https://littlebitesofcocoa.com/topics/39-contacts)

Topics

- [Contacts](https://littlebitesofcocoa.com/topics/39-contacts)
- [Libraries](https://littlebitesofcocoa.com/topics/7-libraries)

## [#187: Picking Contacts with EPContactsPicker 👥](https://littlebitesofcocoa.com/187-picking-contacts-with-epcontactspicker)

 Tuesday February 9th, 2016

Topics

- [Contacts](https://littlebitesofcocoa.com/topics/39-contacts)
- [Libraries](https://littlebitesofcocoa.com/topics/7-libraries)

![Image from bite #187: Picking Contacts with EPContactsPicker](https://media.littlebitesofcocoa.com/bite-assets/187-picking-contacts-with-epcontactspicker-example.png)

In **iOS 9**, the **Contacts** framework replaced **AddressBook.framework** as the suggested way to interact with that data. Today we'll check out a library called [EPContactsPicker](https://github.com/ipraba/EPContactsPicker), which is built on top of the **Contacts framework** and encapsulates a lot of the boilerplate logic. Let's dive in.

```swift
let contactPickerVC = EPContactsPicker(
  delegate: self,
  multiSelection: true,
  subtitleCellType: SubtitleCellValue.Email
)

let nc = UINavigationController(rootViewController: contactPickerVC)
presentViewController(nc, animated: true, completion: nil)
```

Pretty simple! We can add a **delegate function** to grab the contact or contacts that were selected:

```swift
func epContactPicker(_: EPContactsPicker, didSelectMultipleContacts contacts: [EPContact]) {
  for contact in contacts {
    print("\(contact.displayName())")
  }
}
```

More info about *EPContactsPicker* can be found at [git.io/contactspicker](http://git.io/contactspicker)

Topics

- [iOS 9](https://littlebitesofcocoa.com/topics/2-ios-9)
- [Contacts](https://littlebitesofcocoa.com/topics/39-contacts)

## [#24: Contacts and Contacts UI 👥](https://littlebitesofcocoa.com/24-contacts-and-contacts-ui)

 Thursday June 25th, 2015

Topics

- [iOS 9](https://littlebitesofcocoa.com/topics/2-ios-9)
- [Contacts](https://littlebitesofcocoa.com/topics/39-contacts)

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!

![Image from bite #24: Contacts and Contacts UI](https://media.littlebitesofcocoa.com/bite-assets/024-contacts-contacts-ui-example.png)

 

 
