加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

‘DispatchQueue’类型的值没有成员’异步’ – Swift 3

发布时间:2020-12-14 05:25:59 所属栏目:百科 来源:网络整理
导读:我刚刚将 xcode8更新为 Swift 3并收到此错误: Value of type 'DispatchQueue' has no member 'asynchronously' 在这条线上: DispatchQueue.main.asynchronously(execute: 这是整个代码段: DispatchQueue.main.asynchronously(execute: { //Display alert
我刚刚将 xcode8更新为 Swift 3并收到此错误:
Value of type 'DispatchQueue' has no member 'asynchronously'

在这条线上:

DispatchQueue.main.asynchronously(execute:

这是整个代码段:

DispatchQueue.main.asynchronously(execute: {

                        //Display alert message with confirmation
                        let myAlert = UIAlertController(title: "Alert",message:messageToDisplay,preferredStyle: UIAlertControllerStyle.Alert);




                        let okAction = UIAlertAction(title:"OK",style:UIAlertActionStyle.Default){

                            action in self.dismissViewControllerAnimated(true,completion:nil);

                        }

                        myAlert.addAction(okAction)
                        self.presentViewController(myAlert,animated:true,completion:nil);
                    });
                }
            }
            catch let error as NSError {
                print(error.localizedDescription)
            }

        }

        task.resume()

}
}

最近更新到Swift 3给了我很多错误,它们会自动修复,但是这个不会自行解决,我不知道该怎么做.

在Swift 3和iOS 10的生产版本中,没有异步方法.这只是异步:
DispatchQueue.main.async {
    //Display alert message with confirmation
    let alert = UIAlertController(title: "Alert",message: messageToDisplay,preferredStyle: .alert)

    let okAction = UIAlertAction(title: "OK",style: .default) { action in
        self.dismiss(animated: true)
    }

    alert.addAction(okAction)
    self.present(alert,animated: true)
}

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读