Is ABRecordID a reliable way to identify unique contacts?

旧时模样 提交于 2019-12-20 17:38:28

问题


My app uploads contacts, and, in the future, will need to update them. Is using the ABRecordID a reliable way to identify people, or is it possible for a new record to obtain the ID of a deleted record?

To optimize uploads, I would like to upload only the records that have been modified or created since the last upload. I'm currently storing a copy of the person's contacts using core data. I'd like to slim down the footprint of my app and speed up the execution time of scanning through the person's address book looking for modified/new contacts and limit the amount that needs to be uploaded. After analyzing some people's address books, the number of contacts can range from 30 to around 30,000. Dealing with 30,000 contacts is a nightmare.


回答1:


A new record will not obtain an id previously associated with a deleted record. ABRecordIDs are unique in that regard. But they are not necessarily consistent over time, a couple of things can cause the id to change. The user turning on or off iCloud may cause the id to change, as may restoring the device from itunes. That said, ABRecordID is still your best bet for getting a unique id for a contact. You just need to double check that things line up when using it. Apple suggests the following in the address book programming guide:

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.



来源:https://stackoverflow.com/questions/16922150/is-abrecordid-a-reliable-way-to-identify-unique-contacts

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!