gpt4 book ai didi

ios - 匹配来自 IOS 和 OS X 的地址簿记录?

转载 作者:行者123 更新时间:2023-11-29 12:26:34 26 4
gpt4 key购买 nike

有没有办法将 OS X 上的 ABPerson 记录中的唯一标识符与 IOS 上的记录相匹配?乍一看,我无法从我的地址簿中的同一个人那里获得相同的 ID。对于初学者,在 mac 上,属性 kABUIDProperty 是字符串类型,而在 iOS 上,ABRecordID 是整数类型。

所以我的问题是,考虑到两个设备都通过 iCloud 同步,我如何才能在 IOS 和 OS X 上检索相同的 ABPerson 记录。

最佳答案

有同样的问题,所以我决定收集有关主题的所有信息。

来自地址簿编程指南(iOS)

Every record in the Address Book database has a unique record identifier. This identifier always refers to the same record, unless that record is deleted or the data is reset. Record identifiers can be safely passed between threads. They are not guaranteed to remain the same across devices

来自地址簿编程指南 (OSX)

Each group and person has a unique identifier. It’s set when the record is created, and guaranteed never to change even if a user changes the group’s or person’s name or other information. Use this identifier if your application needs to store a reference to a group or person. For more information, see the ABRecord method uniqueId.

但实际上它确实会发生变化,例如当用户关闭/打开 iCloud 时:

http://mjtsai.com/blog/2011/11/07/kabuidproperty/

所以最好的方法是:

The recommended way to keep a long-term reference to a particular record is to store the first and last name, or a hash of the first and last name, in addition to the identifier. When you look up a record by ID, compare the record’s name to your stored name. If they don’t match, use the stored name to find the record, and store the new ID for the record.

还值得一读: Keeping a long-term reference to an IOS AddressBook entry

关于新的联系人框架:

CNContact.identifier

It is recommended that you use the identifier when re-fetching the contact. An identifier can be persisted between the app launches. Note that this identifier only uniquely identifies the contact on the current device.

关于ios - 匹配来自 IOS 和 OS X 的地址簿记录?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28935057/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com