CNLabeledValue identifier on Mac changes after sync with iOS

Hi,


I have a method that imports all the Apple Contact data to a local SQLite database on my Mac (macOS Sierra).


If I make a change to a contact's email addresses, phone numbers, addresses, etc., basically any multi-value field, and then re-import, I'm getting new values coming in instead of the existing values getting updated.


I believe this is because I'm storing the CNLabeledValue's identifier in my database and then using that value as a lookup so that I know which value in the database to update with new data. It would seem that the identifier gets changed if you make a change to the value on iOS and then that contact record syncs over iCloud. However, it's fine if I make a change to the value on macOS. The value in my database gets properly updated. That can only happen, I believe, because the identifier stays the same on the Mac when you make a change to the Contact record in the Apple Contacts app. But when syncing with iOS, those identifiers are being changed.


Do these "unique" identifiers really get changed after a sync? If so, how do you properly deal with that? And how does Apple deal with it because the Contacts app doesn't seem to suffer from this problem.


Thanks,

Brendan