iOS子线程更新UI到主线程的三种方法

// 1.NSThread

[self performSelectorOnMainThread:@selector(updateUI) withObject:nil waitUntilDone:NO];


- (void)updateUI {

    // UI更新代码

    self.alert.text = @"Thanks!";

}


// 2.NSOperationQueue

[[NSOperationQueue mainQueue] addOperationWithBlock:^{

    // UI更新代码

    self.alert.text = @"Thanks!";

    }];


// 3.GCD

dispatch_async(dispatch_get_main_queue(), ^{

   // UI更新代码

   self.alert.text = @"Thanks!";

});



http://blog.csdn.net/cordova/article/details/54933729

你可能感兴趣的:(iOS常用)