0

enter image description here

I have the following error:

Type 'DispatchQueue' has no member 'GlobalAttributes'

In my code. Do you know why?

 public typealias Classification = (Label: DigitLabel, Confidence: CGFloat, BestPrototypeIndex: Int)
    public func classifyDigit(digit: DigitStrokes, votesCounted: Int = 5, scoreCutoff: CGFloat = 0.8) -> Classification? {
        if let normalizedDigit = normalizeDigit(inputDigit: digit) {
            let serviceGroup = DispatchGroup()
            let queue = ***DispatchQueue.global(attributes: DispatchQueue.GlobalAttributes.qosUserInitiated)***
            let serialResultsQueue = DispatchQueue(label: "collect_results")

            var bestMatches = SortedMinArray<CGFloat, (DigitLabel, Int)>(capacity: votesCounted)
            for (label, prototypes) in self.normalizedPrototypeLibrary {

                queue.async(group: serviceGroup) {
                    var localBestMatches = SortedMinArray<CGFloat, (DigitLabel, Int)>(capacity: votesCounted)
                    var index = 0
                    for prototype in prototypes {
                        if prototype.count == digit.count {
                            let score = self.classificationScore(sample: normalizedDigit, prototype: prototype)
                            //if score < scoreCutoff {
                            localBestMatches.add(value: score, element: (label, index))
                            //}
                        }
                        index += 1
                    }
                    serialResultsQueue.async(group: serviceGroup) {
                        for (score, bestMatch) in localBestMatches {
                            bestMatches.add(value: score, element: bestMatch)
                        }
                    }
                }
            }

I also attached the file, just in case.

buczek
  • 2,011
  • 7
  • 29
  • 40

1 Answers1

1

According to Apple's documentation, the message is correct.

Maybe you want to use DispatchQueue.Attributes?

EDIT:

I just had a closer look at the documentation:

DispatchQueue.global() seems to be changed. The documentation shows this declaration:

class func global(qos: DispatchQoS.QoSClass = default) -> DispatchQueue

I tested some variations, Xcode proposed and found this line:

let queue = DispatchQueue.global(qos: DispatchQoS.QoSClass.userInitiated)

I did not test, if this works 100% with your example, but Xcode will compile it

FelixSFD
  • 6,052
  • 10
  • 43
  • 117
  • Now it is "Type 'DispatchQueue.Attributes' has no member 'qosUserInitiated'". – Quoc Dat Do Aug 04 '16 at 15:13
  • I read a bit in the documentation and let Xcode show me some classes I could put in `global()` and found something that will at least compile. Lokk at my edit – FelixSFD Aug 04 '16 at 15:26
  • I'll try it. Thank you. :) – Quoc Dat Do Aug 04 '16 at 15:55
  • oh no now it shows "Command failed due to signal: Segmentation fault: 11" :( (I can post the whole log if you need) http://pastebin.com/kSi3n5HX – Quoc Dat Do Aug 04 '16 at 16:04
  • :-( This can have multiple reasons. Try cleaning the project and restarting Xcode. If it still doesn't work, google for "ios segmentation fault 11". There are tons of different answers about it. Maybe one of them works for you – FelixSFD Aug 04 '16 at 16:09
  • I've tried different solutions and none of them worked. Could you look into the problem for me? It would be very nice of you. – Quoc Dat Do Aug 04 '16 at 16:28
  • http://stackoverflow.com/questions/37805885/how-to-create-dispatch-queue-in-swift-3 – Jason Oct 02 '16 at 15:20
  • DispatchQueue.main.asynchronously(DispatchQueue.main) { self.mapView.add(self.mapPolyline) } in Swift 3.0 i've tried with DispatchQueue.global().asynchronously(DispatchQueue.main) { self.mapView.add(self.mapPolyline) } but both shows the same error as "value of type dispathQuoue has no member asynchronously" – Abirami Bala Oct 06 '16 at 05:32