Skip to content

Commit

Permalink
Protect the runtime hack for user who use before SDWebImage 5.6.0
Browse files Browse the repository at this point in the history
  • Loading branch information
dreampiggy committed Apr 1, 2020
1 parent 96a2832 commit 9b8c19d
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion SDWebImageSwiftUI/Classes/ImageManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,13 @@ public final class ImageManager : ObservableObject {
let transformer = (context?[.imageTransformer] as? SDImageTransformer) ?? manager.transformer
context?[.imageTransformer] = nil
// TODO: before SDWebImage 5.7.0, this is the SPI. Remove later
var key = manager.perform(Selector(("cacheKeyForURL:context:")), with: url, with: context)?.takeUnretainedValue() as? String
var key: String?
let selector = Selector(("cacheKeyForURL:context:"))
if manager.responds(to: selector) {
key = manager.perform(selector, with: url, with: context)?.takeUnretainedValue() as? String
} else {
key = manager.cacheKey(for: url)
}
if let transformer = transformer {
key = SDTransformedKeyForKey(key, transformer.transformerKey)
}
Expand Down

0 comments on commit 9b8c19d

Please sign in to comment.