The performance of inter-thread communication:
1 Threads pass data to another 1 threads
After performing a specific task in 1 threads, go to another 1 thread to continue the task
Here is an example of downloading a picture:
@interface BTThreadViewController () { uiimageview *imagev;} @end- (void) viewdidload{ [super viewdidload]; imagev = [[uiimageview alloc] initwithframe:cgrectmake (100, 100,  100, 100)]; [self.view addsubview:imagev]; //child thread Inside call downimage method download Picture [self performselectorinbackground : @selector (Downimage) withobject:nil];} -(void) downimage{ //download pictures from the network nsurl *url = [nsurl urlwithstring:@ "Http://i8.topit.me/8/c1/31/1142319854bdc31c18o.jpg"]; // Convert a picture to binary data NSData *imgData = [NSData dataWithContentsOfURL:url]; Convert //data into pictures UIImage *img = [UIImage Imagewithdata:imgdata]; //back to main thread settings picture [self Performselectoronmainthread: @selector (senderimage:) withobject:img waituntildone:no];} -(void) Senderimage: (uiimage *) image{ imagev.image = image;}
iOS develops multi-threaded articles---communication between threads