LoginSignup
3
1

More than 5 years have passed since last update.

CNContactからABRecordIDを取り出す

Last updated at Posted at 2015-09-30

iOS9からAddress BookAddress Book UIがduplicatedになり、
代わりにCNcontactを使わないといけないみたいなんですが、CNcontactからABPersonを取得する必要があったので書き留めます。

let iOSLegacyIdentifierKey = "iOSLegacyIdentifier"
guard let recordId = contact?.valueForKey(iOSLegacyIdentifierKey) as? Int32 else {
    return;
}
print(recordId)

これでABRecordIDが取れるので、

ABAddressBookGetPersonWithRecordID(addressBook, recordId)?.takeUnretainedValue()

とかでABPersonを取得できます。

ただし審査通るかはわかりません!

3
1
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
1