Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/22.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios UILabel未在调度组内更新通知_Ios_Objective C_Xcode_Swift_Grand Central Dispatch - Fatal编程技术网

Ios UILabel未在调度组内更新通知

Ios UILabel未在调度组内更新通知,ios,objective-c,xcode,swift,grand-central-dispatch,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文本。您只能从主队列更新UI元素: 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文本。

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

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