dispatch_async
UITextView *text=[[UITextView alloc] initWithFrame:CGRectMake(0, 0, 100, 100)]; [self.view addSubview:text]; __block int count=0; //异步并行处理 dispatch_async(dispatch_get_global_queue(0, 0), ^(){ for (int i=0; i<100; i++) { usleep(10000); count=count+i; } //主线程更新界面 dispatch_sync(dispatch_get_main_queue(), ^(){ text.text=[NSString stringWithFormat:@"%d",count]; }); });