Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/swift/16.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Swift:';Hashable.hashValue';作为协议要求不推荐使用_Swift_Swift5_Hashable - Fatal编程技术网

Swift:';Hashable.hashValue';作为协议要求不推荐使用

Swift:';Hashable.hashValue';作为协议要求不推荐使用,swift,swift5,hashable,Swift,Swift5,Hashable,我在Swift项目中遇到了这个问题: “Hashable.hashValue”作为协议要求不推荐使用;通过改为实现“hash(into:)”将类型“ActiveType”与“Hashable”一致 我试图实现这种方法,但没有成功 删除您的回调属性并添加success属性var success:Bool。顺便说一句,hashValue已被弃用func散列(into-hasher:inout-hasher){hasher.combine(product.productIdentifier)谢谢!此f

我在Swift项目中遇到了这个问题:

“Hashable.hashValue”作为协议要求不推荐使用;通过改为实现“hash(into:)”将类型“ActiveType”与“Hashable”一致

我试图实现这种方法,但没有成功


删除您的
回调
属性并添加
success
属性
var success:Bool
。顺便说一句,hashValue已被弃用
func散列(into-hasher:inout-hasher){hasher.combine(product.productIdentifier)
谢谢!此
func散列(into-hasher:inout-hasher){hasher.combine(product.productIdentifier)}
修复了该问题。
struct Payment: Hashable {
    let product: SKProduct
    let quantity: Int
    let atomically: Bool
    let applicationUsername: String
    let simulatesAskToBuyInSandbox: Bool
    let callback: (TransactionResult) -> Void

    var hashValue: Int {
        return product.productIdentifier.hashValue
    }

    static func == (lhs: Payment, rhs: Payment) -> Bool {
        return lhs.product.productIdentifier == rhs.product.productIdentifier
    }
}