Skip to Content
iOS 9 Swift Programming Cookbook
book

iOS 9 Swift Programming Cookbook

by Vandad Nahavandipoor
December 2015
Intermediate to advanced
350 pages
6h 32m
English
O'Reilly Media, Inc.
Content preview from iOS 9 Swift Programming Cookbook

Chapter 4. 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 we have the CNContact object that represents a contact. You get access to the contacts’ database using the CNContactStore class.

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 authorizationStatusForEntityType(_:) 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 requestAccessForEntityType(_: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 have not been fetched yet can later be fetched from the store using her identifier (part of the CNContact object). ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

iOS 10 Swift Programming Cookbook

iOS 10 Swift Programming Cookbook

Vandad Nahavandipoor

Publisher Resources

ISBN: 9781491936689Errata Page