I have just started on a project and have come across a deprecated function. After googling around I've found several solutions but only for the first part of the error. My issue is i dont know how to deal with the nested parts that are also deprecated. The function is as follows:
private static func compute(data: Data, operation: Int) -> Data {
    let cryptLength = size_t(data.count + kCCBlockSizeAES128)
    var cryptData = Data(count:cryptLength)
    let keyLength = size_t(kCCKeySizeAES128)
    let options = CCOptions(kCCOptionPKCS7Padding)
    var numBytesEncrypted: size_t = 0
    let cryptStatus = cryptData.withUnsafeMutableBytes { cryptBytes in  <--- Warning 1
        data.withUnsafeBytes { dataBytes in  <--- Warning 2
            Data(Encoded.iv).withUnsafeBytes { ivBytes in  <--- Warning 3
                Data(Encoded.key).withUnsafeBytes { keyBytes in  <--- Warning 4
                    CCCrypt(CCOperation(operation),
                            CCAlgorithm(kCCAlgorithmAES),
                            options,
                            keyBytes, keyLength,
                            ivBytes,
                            dataBytes, data.count,
                            cryptBytes, cryptLength,
                            &numBytesEncrypted)
                }
            }
        }
    }
    guard case UInt32(cryptStatus) == UInt32(kCCSuccess) = true else {
        print("Something went wrong: \(cryptStatus)")
        return cryptData
    }
    cryptData.removeSubrange(numBytesEncrypted..<cryptData.count)
    return cryptData
}
Warning 1: 'withUnsafeMutableBytes' is deprecated: use `withUnsafeMutableBytes<R>(_: (UnsafeMutableRawBufferPointer) throws -> R) rethrows -> R` instead
Warning 2,3 + 4: 'withUnsafeBytes' is deprecated: use `withUnsafeBytes<R>(_: (UnsafeRawBufferPointer) throws -> R) rethrows -> R` instead
I've tried doing cryptData.withUnsafeMutableBytes { (cryptBytes: UnsafeMutablePointer) in or adding try around each but either get new errors or the warning stays.
Can anyone help?
