multithreading - How can I ensure that NSOperationQueue uses only one thread? -


abaddressbookref can accessed 1 thread. think model having thread abaddressbookref in background, besides main thread.

how can ensure there's 1 thread while using nsoperationqueue? setting max concurrency 1 won't guarantee run on same thread.

should use other unique threads web threads?

you can manually create thread , redirect address book access it.

you create thread (adapted documentation):

nsthread* mythread = [[nsthread alloc] initwithtarget:[mythread new]                                     selector:@selector(mythreadmainmethod)                                     object:nil]; [mythread start];  // create thread 

note thread useful, have implement run loop in thread's main method.

see example implementation of run loop in answer.

you able do stuff on thread using nsobject's method performselector:onthread:withobject:waituntildone:.

here's wrapper library abaddressbookref implements concept – rhaddressbook.


Comments

Popular posts from this blog

user interface - Python attempting to create a simple gui, getting "AttributeError: 'MainMenu' object has no attribute 'intro_screen'" -

jquery - Common JavaScript snippet to share files on Google Drive, Dropbox, Box.net or SkyDrive -

Android Gson.fromJson error -