1

After Xcode conversion to Swift 3.0 syntax, I got the following error:

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 {

Syntax after conversion :

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()
            }
        }
    }

}

Syntax before conversion :

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()
            }
        }
    }

}
vadian
  • 274,689
  • 30
  • 353
  • 361
FishCode
  • 15
  • 4
  • 1
    Possible duplicate of [How do I dispatch\_sync, dispatch\_async, dispatch\_after, etc in Swift 3?](http://stackoverflow.com/questions/37801370/how-do-i-dispatch-sync-dispatch-async-dispatch-after-etc-in-swift-3) – Hamish Mar 12 '17 at 11:44

1 Answers1

1

It's simply

DispatchQueue.global(qos: .userInitiated).async { }
vadian
  • 274,689
  • 30
  • 353
  • 361