Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How do I display an APContact using ABPersonViewController? #123

Open
tomvanzummeren opened this issue Mar 27, 2016 · 3 comments
Open

How do I display an APContact using ABPersonViewController? #123

tomvanzummeren opened this issue Mar 27, 2016 · 3 comments

Comments

@tomvanzummeren
Copy link

How do I display an APContact using ABPersonViewController?

Or can APAddressBook supply me with a built in controller? What are my options here? I just want to use some pre-built controller that shows me the details of a single APContact. Can this be done?

@belkevich
Copy link
Contributor

Unfortunately, there are no any UI in 'APAddressBook' and it don't compatible with any out-of-the-box solutions like 'ABPersonViewController'

@tomvanzummeren
Copy link
Author

I found a way to do it!

let apContact: APContact = ...

let recordId = ABRecordID(apContact.recordID.intValue)
let ab = ABAddressBookCreateWithOptions(nil, nil).takeRetainedValue()
let abRecord = ABAddressBookGetPersonWithRecordID(ab, recordId).takeUnretainedValue()

let controller = ABPersonViewController()
controller.displayedPerson = abRecord
navigationController?.pushViewController(controller, animated: true)

@belkevich
Copy link
Contributor

Looks good!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants