I am trying to convert ABRecordRef to NSdata, but I am not sure how to achieve it. I want to save ABRecordRef to sqlite database and then after some time to add the same ABRecordRef to address book. I have tried this, but I am not sure whether it is the right way or not
NSData *d = [[NSData alloc] initWithBytes:ref length:sizeof(ref)];
or something like this
NSData *data= (NSData *) ref;
it would be great if you showed me some way to convert it to NSdata and then back to ABRecordRef.
And is there any way I can store NSdata or directly ABRecordRef to sqlite database?
I think the same question is answered here.
Basically, what you are trying to do won't work because you are mixing plain C types with Objective-C types. Instead, what you could do is copy all the relevant properties of the
ABRecordto anNSDictionary(or your own customNSObject) and then serialize/deserialize that instead.