one of the basic principles of the architecture of my last application is that I am going to call methods in the application model that will be asynchronous and will accept blocks of failure and success script.
ie UI calls a model method with two blocks, one for success and one for failure.
This is great because the context of the original call is preserved, however the block itself is called in the background thread. Is there a way to call a block on the main thread?
I hope I explained this, if not, basically my model methods are asynchronized, return immediately and create a new thread on which op runs. As soon as op returns, I will call the block that will process the returned data, THEN I need to call the block for the success script defined by the callable inside the user interface. However, the success and failure scenario blocks defined in the user interface must be called in the main thread because I need to interact with the user interface elements that should only be executed in the main thread that I trust.
many thanks
objective-c iphone ipad
krisdyson
source share