gpt4 book ai didi

swift3 - 转换为Swift3错误

转载 作者:行者123 更新时间:2023-12-03 08:08:07 25 4
gpt4 key购买 nike

Xcode转换为Swift 3.0语法后,出现以下错误:

error: cannot invoke initializer for type 'Int' with an argument list of type '(qos_class_t)' DispatchQueue.global(priority: Int(DispatchQoS.QoSClass.userInitiated.rawValue)).async { ^

note: overloads for 'Int' exist with these partially matching parameter lists: (Int64), (Word), (UInt8), (Int8), (UInt16), (Int16), (UInt32), (Int32), (UInt64), (UInt), (Int), (Float), (Double), (Float80), (String, radix: Int), (CGFloat), (NSNumber) {DispatchQueue.global(priority: Int(DispatchQoS.QoSClass.userInitiated.rawValue)).async {



转换后的语法:
func searchBar(_ searchBar: UISearchBar, textDidChange searchText: String) {

if searchText == "" {
self.filteredSymbols = self.symbols
self.alphabeticSymbolCollection.reloadData()
} else {
DispatchQueue.global(priority: Int(DispatchQoS.QoSClass.userInitiated.rawValue)).async {
let fs = self.filterContentForSearchText(searchText)
DispatchQueue.main.async {
self.filteredSymbols = fs

self.searchActive = true

self.alphabeticSymbolCollection.reloadData()
}
}
}

}

转换前的语法:
func searchBar(searchBar: UISearchBar, textDidChange searchText: String) {

if searchText == "" {
self.filteredSymbols = self.symbols
self.alphabeticSymbolCollection.reloadData()
} else {
dispatch_async(dispatch_get_global_queue(Int(QOS_CLASS_USER_INITIATED.rawValue), 0)) {
let fs = self.filterContentForSearchText(searchText)
dispatch_async(dispatch_get_main_queue()) {
self.filteredSymbols = fs

self.searchActive = true

self.alphabeticSymbolCollection.reloadData()
}
}
}

}

最佳答案

简直就是

DispatchQueue.global(qos: .userInitiated).async { }

关于swift3 - 转换为Swift3错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42744493/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com