Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Identify ABRecord records uniquely: Is [ABRecord uniqueId] immutable?

I need to reference ABPerson records from within an application. I use the unique ID provided by

  - (NSString *)uniqueId

and attach it to my in-app contact record.

Additionally, I save ABPerson's vCardRepresentation as a fallback. In case the app isn't any longer able to locate the ABRecord using the uniqueID, the app asks the user to recover the adressbook record using the saved vCardRepresentation. All works fine.

Unfortunately, a friend told me, that uniqueId isn't immutable: During a sync, uniqueId may suddenly change.

According to him, somewhere in iOS documentation, Apple explains that no way exists to immutable identify ABPersons using uniqueId. In OS X' Cocoa documentation, I failed to find such a hint.

On a given Mac, may the uniqueId change suddenly? If that's true, what's the correct way to identify ABPerson records from within an external application?

In case the uniqueID isn't immutable, I certainly may assign a custom property with a GUID. Unfortunately, custom fields do not sync.

Certainly, I'd prefer to use uniqueId.

like image 805
SteAp Avatar asked Aug 16 '11 20:08

SteAp


2 Answers

For whats its worth, from Apple's techdoc:

kABUIDProperty The unique ID for this record. It’s guaranteed never to change, no matter how much the record changes. If you need to store a reference to a record, use this value. Type: kABStringProperty. Available in Mac OS X v10.2 and later. Declared in ABGlobals.h.

like image 170
Roger Avatar answered Oct 19 '22 08:10

Roger


It looks like the kABUIDProperty approach might not work anymore. I came across this blog entry with more discussion in the comments at:
http://blog.clickablebliss.com/2011/11/07/addressbook-record-identifiers-on-mac-and-ios/.

A case in point: If a user decides to turn on iCloud sync, the unique ids in that user's address book will change. If the users turns off iCloud sync, they'll change again.

Addendum: it might be worthwhile looking at the StackOverflow entry here.

Apple's docs do say this (quoted from the link):

"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."

like image 26
Mark Semsel Avatar answered Oct 19 '22 06:10

Mark Semsel