UILabel不在dispatch_group_notify内更新

时间:2014-11-11 16:20:29

标签: ios objective-c xcode swift grand-central-dispatch

为什么这不起作用?

dispatch_group_notify(group, dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0)) { () -> Void in
    println("Howdy, I get called")
    self.myLabel.text = "Hello Mr. Gordon Freeman"
}

打印邮件但未设置UILabel文本。

1 个答案:

答案 0 :(得分:1)

您只能更新主队列中的UI元素:

dispatch_group_notify(group, dispatch_get_main_queue()) {
    println("Howdy, I get called")
    self.myLabel.text = "Hello Mr. Gordon Freeman"
}