Browse Source

Fix warning for image class

onevcat 1 year ago
parent
commit
bc11fd04d7
1 changed files with 9 additions and 9 deletions
  1. 9 9
      Sources/Image/Image.swift

+ 9 - 9
Sources/Image/Image.swift

@@ -45,20 +45,20 @@ import ImageIO
 import UniformTypeIdentifiers
 import UniformTypeIdentifiers
 #endif
 #endif
 
 
-private var animatedImageDataKey: Void?
-private var imageFrameCountKey: Void?
-private var imageSourceKey: Void?
+private let animatedImageDataKey = malloc(1)!
+private let imageFrameCountKey = malloc(1)!
+private let imageSourceKey = malloc(1)!
 
 
 // MARK: - Image Properties
 // MARK: - Image Properties
 extension KingfisherWrapper where Base: KFCrossPlatformImage {
 extension KingfisherWrapper where Base: KFCrossPlatformImage {
     private(set) var animatedImageData: Data? {
     private(set) var animatedImageData: Data? {
-        get { return getAssociatedObject(base, &animatedImageDataKey) }
-        set { setRetainedAssociatedObject(base, &animatedImageDataKey, newValue) }
+        get { return getAssociatedObject(base, animatedImageDataKey) }
+        set { setRetainedAssociatedObject(base, animatedImageDataKey, newValue) }
     }
     }
     
     
     public var imageFrameCount: Int? {
     public var imageFrameCount: Int? {
-        get { return getAssociatedObject(base, &imageFrameCountKey) }
-        set { setRetainedAssociatedObject(base, &imageFrameCountKey, newValue) }
+        get { return getAssociatedObject(base, imageFrameCountKey) }
+        set { setRetainedAssociatedObject(base, imageFrameCountKey, newValue) }
     }
     }
     
     
     #if os(macOS)
     #if os(macOS)
@@ -105,8 +105,8 @@ extension KingfisherWrapper where Base: KFCrossPlatformImage {
     
     
     /// The custom frame source for the current image.
     /// The custom frame source for the current image.
     public private(set) var frameSource: ImageFrameSource? {
     public private(set) var frameSource: ImageFrameSource? {
-        get { return getAssociatedObject(base, &imageSourceKey) }
-        set { setRetainedAssociatedObject(base, &imageSourceKey, newValue) }
+        get { return getAssociatedObject(base, imageSourceKey) }
+        set { setRetainedAssociatedObject(base, imageSourceKey, newValue) }
     }
     }
 
 
     // Bitmap memory cost with bytes.
     // Bitmap memory cost with bytes.