From 79b6f72db2cbbe41831d6bb2729949bafa4d9ecd Mon Sep 17 00:00:00 2001 From: Alexey Alter-Pesotskiy Date: Thu, 19 Oct 2023 14:49:26 +0100 Subject: [PATCH] Resolve UnsafeRawPointer warning --- .../StreamNuke/Nuke/Processing/ImageDecompression.swift | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Sources/StreamChatSwiftUI/StreamNuke/Nuke/Processing/ImageDecompression.swift b/Sources/StreamChatSwiftUI/StreamNuke/Nuke/Processing/ImageDecompression.swift index 5b2870749..d9db20145 100644 --- a/Sources/StreamChatSwiftUI/StreamNuke/Nuke/Processing/ImageDecompression.swift +++ b/Sources/StreamChatSwiftUI/StreamNuke/Nuke/Processing/ImageDecompression.swift @@ -15,10 +15,14 @@ enum ImageDecompression { static var isDecompressionNeededAK = "ImageDecompressor.isDecompressionNeeded.AssociatedKey" static func setDecompressionNeeded(_ isDecompressionNeeded: Bool, for image: PlatformImage) { - objc_setAssociatedObject(image, &isDecompressionNeededAK, isDecompressionNeeded, .OBJC_ASSOCIATION_RETAIN) + withUnsafePointer(to: &isDecompressionNeededAK) { keyPointer in + objc_setAssociatedObject(image, keyPointer, isDecompressionNeeded, .OBJC_ASSOCIATION_RETAIN) + } } static func isDecompressionNeeded(for image: PlatformImage) -> Bool? { - objc_getAssociatedObject(image, &isDecompressionNeededAK) as? Bool + return withUnsafePointer(to: &isDecompressionNeededAK) { keyPointer in + objc_getAssociatedObject(image, keyPointer) as? Bool + } } }