views:

411

answers:

1

What’s considered ‘best practice’ when saving Address Book contacts in Core Data?

I’m writing an iPhone App, based on Core Data, where I need to save and recall Address Book contacts as part of the data model.

In the UI I plan to present a screen where the user can pick a contact from the current Address Book, create a new contact to store in the Address Book, or just create a ‘one-off’ contact with no saved record, local to the App only. These contacts are tracked in the context of the orders they have made, and not all contacts will require saving outside the App itself.

It feels ‘wrong’ to copy the data from the Address Book if using an existing entry, but not sure what to do if an Address Book record is edited or deleted.

I only need to track name and photo for the purposes of the App, so gut-reaction is to store the ABRecordID, and—because these can apparently change(!)—the first and last name, and only update local record if it’s updated (how to track that?).

Or can you store a ABRecordRef directly? (I imagine they aren’t persistent?)

I’ve done some searching on Google, and here, but can’t find any code samples or discussion on the integration of Core Data and Address Book in this manner; just lots of stuff on each in isolation.

Any one with some experience/gotchas on this subject point them out, or point me in the direction of some more reading?

Thanks.

Andy W

+2  A: 

I would store the ABRecordID and then handle the situation for when they change although I have not personally seen a case where they change except when the user deletes all data and restores it from another source (moving from MobileMe to Google for example).

Marcus S. Zarra