Created
August 4, 2015 17:25
-
-
Save eugeniobaglieri/0066fbb4eebb8b96b761 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// ContactPicker.swift | |
// SwipeAndCall | |
// | |
// Created by Eugenio Baglieri on 04/08/15. | |
// Copyright © 2015 Eugenio Baglieri. All rights reserved. | |
// | |
import AddressBookUI | |
import ContactsUI | |
class ContactPicker: NSObject { | |
private(set) lazy var picker: UIViewController = { | |
if #available(iOS 9.0, *) { | |
let contactPicker = CNContactPickerViewController() | |
contactPicker.delegate = self | |
return contactPicker | |
} else { | |
let peoplePicker = ABPeoplePickerNavigationController() | |
peoplePicker.peoplePickerDelegate = self | |
return peoplePicker | |
} | |
}() | |
} | |
@available(iOS 9.0, *) | |
extension ContactPicker: CNContactPickerDelegate { | |
func contactPickerDidCancel(picker: CNContactPickerViewController) { | |
} | |
func contactPicker(picker: CNContactPickerViewController, didSelectContact contact: CNContact) { | |
} | |
} | |
@available(iOS 2.0, *) | |
extension ContactPicker: ABPeoplePickerNavigationControllerDelegate { | |
func peoplePickerNavigationControllerDidCancel(peoplePicker: ABPeoplePickerNavigationController) { | |
} | |
func peoplePickerNavigationController(peoplePicker: ABPeoplePickerNavigationController, didSelectPerson person: ABRecord) { | |
} | |
func peoplePickerNavigationController(peoplePicker: ABPeoplePickerNavigationController, shouldContinueAfterSelectingPerson person: ABRecord) -> Bool { | |
return false | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment