objective c - How to properly use address book for background thread? -


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 move different thread.

however 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 should do?

should create new abaddressbookref different thread? that's approach core data right? create new nsmanagedobjectcontext different thread?

one solution can think of create new address book each thread

-(abrecordref) abrecordref {     abaddressbookref _addressbook;     _addressbook =abaddressbookcreate();     abrecordref abr = abaddressbookgetpersonwithrecordid (_addressbook,self.recordid);     cfrelease(_addressbook);     return abr; } 

but means abr "survive" without abaddressbookref. okay?

that makes things more slow way because abaddressbookcreate quite cpu incentive.

the docs state:

important: must ensure instance of abaddressbookref used 1 thread.

so yes, have create 1 per thread. should clearer actual problem however, can suggest more suitable solutions.


Comments

Popular posts from this blog

.htaccess - First slash is removed after domain when entering a webpage in the browser -

Automatically create pages in phpfox -

c# - Farseer ContactListener is not working -