小编Hem*_*ack的帖子

重叠访问"结果",但修改需要独占访问; 考虑复制到xcode 10中的局部变量

open static func PBKDF2(_ password: String, salt: Data,
                                 prf: PRFAlg, rounds: UInt32) throws -> Data {

            var result = Data(count:prf.cc.digestLength)
            let passwData = password.data(using: String.Encoding.utf8)!
            let status = result.withUnsafeMutableBytes {
                (passwDataBytes: UnsafeMutablePointer<UInt8>) -> CCCryptorStatus in
                return CCKeyDerivationPBKDF!(PBKDFAlgorithm.pbkdf2.rawValue,
                                             (passwData as NSData).bytes, passwData.count,
                                             (salt as NSData).bytes, salt.count,
                                             prf.rawValue, rounds,
                                             passwDataBytes, result.count)
            }
            guard status == noErr else { throw CCError(status) }

            return result
        }
Run Code Online (Sandbox Code Playgroud)

result.withUnsafeMutableBytes在Xcode 10中给出错误,在Xcode 9中它是一个警告.

ios swift

8
推荐指数
1
解决办法
4075
查看次数

标签 统计

ios ×1

swift ×1