UIImage* image;
if(ABPersonHasImageData(self.abRecordRef)){
image = [UIImage imageWithData:(__bridge_transfer NSData *)ABPersonCopyImageData(self.abRecordRef)];
}
-(ABRecordRef) abRecordRef
{
ABRecordRef abR = ABAddressBookGetPersonWithRecordID ([RCABAddressBookHandler addressBook],self.recordID);
return abR;
}
I want to move this to a different thread.
However the definition of addressBook is
+(ABAddressBookRef) addressBook
{
return [RCABAddressBookHandler singleton].addressBook;
}
and
it's declared as
@property (nonatomic) ABAddressBookRef addressBook;
And that's not type safe.
So what should I do?
Should I create new ABAddressBookRef for different thread? That's the approach for core data right? Create new nsmanagedobjectcontext for different thread?
One solution I can think of is to just create a new address book for each thread
-(ABRecordRef) abRecordRef
{
ABAddressBookRef _addressBook;
_addressBook =ABAddressBookCreate();
ABRecordRef abR = ABAddressBookGetPersonWithRecordID (_addressBook,self.recordID);
CFRelease(_addressBook);
return abR;
}
But that means the abR will "survive" without any ABAddressBookRef. Is it even okay?
That makes things even more slow by the way because ABAddressBookCreate actually is quite CPU incentive.