Saving ABRecordRef in Master Data

I would like to save ABRecordRef in the Client object in the master data.

I read in the apples documentation that ABRecordRef is a primitive data type C. As far as I know, you can only insert objects in the main data. With that in mind, what's the best way to store it in master data?

I was thinking of converting it to NSNumber for storage, but don't know how to convert it back to ABRecordRef for use.

I also thought that I could just put it in an NSArray / NSSet / NSDictionary on my own, just acting like a wrapper, but didn't know if it was stupid / inefficient / even worked.

Thoughts appreciated.

Many thanks

+4
source share
1 answer

In one of my applications, I just saved ABRecordGetRecordID () as INT32 in the CoreData repository (since ABRecordID is int32_t), and also saved the contact name in the CoreData repository for quick display. Thus, the record information is stored in the address book where it belongs, and you just saved a "pointer" to the record in your CoreData repository.

You could then create handy wrappers in your custom NSManagedObject that will transfer C calls to the AB structure according to your needs.

+12
source

Source: https://habr.com/ru/post/1397328/


All Articles