multithreading - Background (Asynchronous) programming in Cocoa/Objective-C -
i want similar c#'s backgroundworker
.
i want execute block code of code (irrespective of kind of code is. networking, i/o, complex math operations, whatever) in background while animate nsprogressindicator
. 1 time operation complete, not want hide progress indicator want receive result object(s) background code main code.
what best way this?
thanks help!
you may want reading nsoperation, nsoperationqueue, , blocks.
using these can execute "block" of code asynchronously , have "schedule" update of progress indicator on main thread every often. can set completion block (callback) execute when operation finish , can phone call function executed on main thread.
this article provides nice overview of options little examples.
this answer provides illustration defining , using completion block.
objective-c multithreading cocoa asynchronous background-process
No comments:
Post a Comment