I\'m writing a client-server app to iPhone. And I have a question about threading. When I access my online database from the device, I need to do this on a separate thread to no
since you are passing instance variables, another option would be to pass self and make self thread safe.
Well, you're already using dispatch_async
. Then you should just use
dispatch_async(dispatch_get_main_queue(),^ { ... } );
from inside your background thread to perform things on the main thread. For example,
if ([self testServerMethod])
{
dispatch_async(dispatch_get_main_queue(),^ {
[self showMessageBoxWithString: @"Server is working!"];
[self threadedUIActivityRemover:nil];
} );
}else ...
It doesn't have any constraint on the number of arguments for the methods you call.
Pass a collection, such as a dictionary of unarchived objects.
You can also use an NSInvocation
.