Is there any sample code for doing mulitithreading tasks on iPhone?
I have a slow internet task to save and load a file, I would like to do these slow tasks on some background thread. I am wondering if this can be done, and if so, some example code?
Then, upon completion, I want it to pay attention to the main thread so that I can update the interface.
source to share
Ultimately, the device your code is running on has a single processor and cannot load large amounts (gigabytes) of data. The best route is probably the one suggested by Ben (NSURLConnection asynchronously), which gives you the added benefit of being able to cleanly cancel and handle error messages. While this is not technically sliced ββinto what you probably think you want, it integrates well with the event loop and is not blocking. If that's not enough yet, I would suggest looking at NSOperation and NSOperationQueue. You can start the NSOperation sub-class object and do the load there (I would still recommend doing it asynchronously there to enable undo, suspend, etc.).
source to share