У меня есть 3 места (всего 7 предупреждений) в проекте, где XCode показывает следующее предупреждение:
withUnsafeMutableBytes 'устарело
Я пытался решить эти предупреждения самостоятельно, но безуспешно. Кто-нибудь может мне помочь?
1. let status = cryptData.withUnsafeMutableBytes {ivBytes in
SecRandomCopyBytes(kSecRandomDefault, kCCBlockSizeAES128, ivBytes)
}
2. let cryptStatus = cryptData.withUnsafeMutableBytes {cryptBytes in
data.withUnsafeBytes {dataBytes in
keyData.withUnsafeBytes {keyBytes in
CCCrypt(CCOperation(kCCEncrypt),
CCAlgorithm(kCCAlgorithmAES),
options,
keyBytes,
keyLength,
cryptBytes,
dataBytes,
data.count,
cryptBytes + kCCBlockSizeAES128,
cryptLength,
&numBytesEncrypted)
}
}
}
3. let cryptStatus = clearData.withUnsafeMutableBytes {cryptBytes in
data.withUnsafeBytes {dataBytes in
keyData.withUnsafeBytes {keyBytes in
CCCrypt(CCOperation(kCCDecrypt),
CCAlgorithm(kCCAlgorithmAES128),
options,
keyBytes,
keyLength,
dataBytes,
dataBytes + kCCBlockSizeAES128,
clearLength,
cryptBytes,
clearLength,
&numBytesDecrypted)
}
}
}