asynchronous - objective c, notify other threads -


my task download content, parse it, save in database , update ui after completion (or notify user error). used in different parts of application, want extract code separate class , use asynchronous facade. use nsurlconnection handle network tasks. nsurlconnection calls callbacks in separate thread. ui code should run in main thread. store set of blocks call , invoke them main thread dispatch_async, means main thread hardcoded. looks me want reinvent wheel , there should mechanism used in objective c communicate between threads, can't find it. want:

receivers subscribe receive messages given identifier , specifying thread notifications should dispatched.

sender sends message identifier , attached data.

all subscribed receivers message in threads specified.

or there pattern appropriate task?

you can use nsnotificationcenter communicate between objects running on different thread.and post notification different thread.

see apple nsnotificationcenter documentation

to update ui elements on main thread use [self performselectoronmainthread:@selector(somefunction) withobject:nil waituntildone:no];


Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

How to get the ip address of VM and use it to configure SSH connection dynamically in Ansible -

javascript - Get parameter of GET request -