gpt4 book ai didi

iOS - 类型 'DispatchQueue' 没有成员 'GlobalAttributes'

转载 作者:行者123 更新时间:2023-11-28 16:18:28 25 4
gpt4 key购买 nike

enter image description here

我有以下错误:

Type 'DispatchQueue' has no member 'GlobalAttributes'

在我的代码中。你知道为什么吗?

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

我还附上了the file ,以防万一。

最佳答案

根据 Apple's documentation , 消息是正确的。

也许您想使用 DispatchQueue.Attributes

编辑:

我刚刚仔细查看了文档:

DispatchQueue.global() 似乎已更改。文档显示了这个声明:

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

我测试了一些变体,Xcode 提出并找到了这一行:

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

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

关于iOS - 类型 'DispatchQueue' 没有成员 'GlobalAttributes',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38771016/

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