From b4a09bf6a34ef9e62263425f67c2afe307798f3b Mon Sep 17 00:00:00 2001 From: SiyuanLi Date: Wed, 12 Jun 2024 22:24:52 +0900 Subject: [PATCH] Update deprecated method usage in encryption example - Replaced the usage of `withUnsafeMutableBytes` with a more modern and safe approach in the example code that generates a random encryption key. - This update ensures compatibility with modern Swift versions and prevents potential warnings. --- README.md | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 37e23691c3..e94eda87a8 100644 --- a/README.md +++ b/README.md @@ -107,8 +107,11 @@ Data can be encrypted in-flight and at-rest, keeping even the most sensitive dat ```swift // Generate a random encryption key var key = Data(count: 64) -_ = key.withUnsafeMutableBytes { bytes in - SecRandomCopyBytes(kSecRandomDefault, 64, bytes) +_ = key.withUnsafeMutableBytes { (pointer: UnsafeMutableRawBufferPointer) in + guard let baseAddress = pointer.baseAddress else { + fatalError("Failed to obtain base address") + } + SecRandomCopyBytes(kSecRandomDefault, 64, baseAddress) } // Add the encryption key to the config and open the realm