How does multithreading work in Objective-C on the iPhone?

11,672

You need multi-threading in objective c because sometimes you need functions/code to run "in the background" (read: on another thread). For instance (but not explicitly) you might need to download large amounts of data off the internet (a picture, or a video).

In this case running the download on the 'main' thread will cause the iphone to freeze before the download is complete. So you use multi-threading to download the data AND let the iphone work all at the same time.

There are lots of ways to do multithreading in objective-c. To be honest you need to look it up yourself, we're not here to just spoonfeed you.

Things to look up are: NSURLConnection and the method [self performSelector:onThread:...]

Share:
11,672
user428149
Author by

user428149

Updated on June 05, 2022

Comments

  • user428149
    user428149 almost 2 years

    I'm confused about the concept of "threads" in iPhone development:

    • Why are threads necessary / useful?
    • How can threads be used in Objective-C?