Access contact image from address book based on its id
===

As every one is aware of the fact that we can create an address book(ABAddressBook),get is count and then create a record reference(ABRecordRef),then copy its image data using NSData as follows:

    ABAddressBookRef addressBook = ABAddressBookCreate( );
    CFArrayRef allPeople = ABAddressBookCopyArrayOfAllPeople( addressBook );
    ABRecordRef recordReference = CFArrayGetValueAtIndex(allPeople, addressIndex);
    NSData *imageData = (NSData *)ABPersonCopyImageData(recordReference);

Now this works fine as expected to be a universal fact,but in my case(application),I have a tiny problem,what if the user saves a contact initially and doesn't add/upload any image,then at the time,we are accessing the image data from that contact,we are having empty image,thus I give or assign a default image.But what if the user uploads image for a contact later on or modifies an existing for a contact,which means the updated image must will not appear and we can't rely on address book name or some index etc..

Hence I came up with an idea of saving the unique contact id,then get the contact image based on its id.In the process I have saved the unique contact id in to database,now what next,holding the id value using model class,then saving that model class in to array.

This is the sample code for understanding:

    ReminderClass *reminderToDisplay = [self.remindersArray objectAtIndex:indexPath.row];
    NSString *contactImagePathID = reminderToDisplay.contactImageID;
    int addressIndex = [contactImagePathID integerValue];

Now as we are aware of the fact that we can have an instance of ABRecordRef and thus copy its image data,but as we know it's syntax would be:

    ABRecordRef personID = CFArrayGetValueAtIndex(CFArrayRef theArray, CFIndex idx);

Any way I can assign **addressIndex** in the place of **CFIndex idx**

But I am struck with the array part,i.e. **CFArrayRef**,as I have an NSMutableArray holding all the id details,i.e. **remindersArray**

Now I have searched for type casting methods from **NSMutableArray** to **CFArrayRef**
But found a few questions on vice-versa,a sample question over <a href="http://stackoverflow.com/questions/8761461/how-to-make-an-cfarrayref-to-an-nsmutablearray">here</a>

Please guide me if there is any way to get over this,so that I can gain access to proper images for respective contacts,Any help is greatly appreciated!

Thanks all in advance :)