Khushbu Shah
Khushbu Shah

Reputation: 1683

Store contacts in own application in iphone

I am new to iPhone application development. My application has its own contact screen which has all contacts of phone book and also application's contacts in single list. My application should store all contacts in its dataabse, it should not display contact screen like contact picker opens. For this I have created entity of contact to store contacts in my application's persistent store. I have read iphone's contacts using AddessBook APIs. I am facing some problems in that.

  1. Problem in storing contact image : To get contact image I have used ABPersonCopyImageData. It returns CFDataRef. How can we store CFDataRef in database and retrieve it. Because there are only primitive data types available in entity's attribute type (NSArry type is not available).

  2. Problem in storing Multivalue Properties : If any any contact has multiple numbers, then we received multiple value for number. Is there any API or mechanism available in core data ? or we have to store them using custom mechanism like using delimiter.

Upvotes: 0

Views: 199

Answers (2)

Prakash Desai
Prakash Desai

Reputation: 511

if I was you then i would be storing images in document directory convert CFDataRef into NSData and then UIImage you can convert CFDataRef to NSData simply like this

NSData *myData = (NSData *)myCFDataRef;

then convert it to UIImage like this

UIImage *image=[UIImage imageWithData:myData];

and store it in document directory with different name like test_1.png where 1 is intiger which you increment every time for new image name

and in database store only location string

Upvotes: 1

LittleIDev
LittleIDev

Reputation: 921

Problem 1:- You can convert CFDataRef to UIImage and store that in database using datatype "Transformable"

Problem 2:- You have to save that using any delimeter or you can create different attributes for that.

Hope this help you.

Upvotes: 0

Related Questions