#StackBounty: #ios #swift #xcode withUnsafeMutableBytes' is deprecated xcode warning

Bounty: 200

I have 3 places (in total 7 warnings) in the project where XCode shows the next warning:

withUnsafeMutableBytes’ is deprecated

I tried on my own to resolves these warnings, but with no luck. Can someone help me?

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


Get this bounty!!!

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.