1

我创建了一个线程,现在我想从线程发送消息(执行特定事件)到主 GUI 线程,以便 GUI 线程可以执行我的消息。谁能告诉我如何在 iphone 中执行此操作(目标 C)

4

2 回答 2

3
  //This will call selected method on main thread and you can do what ever you want to do in your selected method.

[self performSelectorOnMainThread:@selector(yourmethod) withObject:yourobject waitUntilDone:NO];

希望对你有帮助..

于 2012-04-27T04:19:41.557 回答
1

您可以使用 GCD 和块

dispatch_async(dispatch_get_main_queue(), ^{
    // UI code to run on main thread
});
于 2012-04-27T04:24:45.793 回答