我创建了一个线程,现在我想从线程向主GUI线程发送消息(做特定事件),这样GUI线程就可以执行我的message.can任何一个告诉我如何做到这一点在iphone(Objective C)
答案 0 :(得分: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];
希望,这会对你有帮助..
答案 1 :(得分:1)
您可以使用GCD和阻止
dispatch_async(dispatch_get_main_queue(), ^{
// UI code to run on main thread
});