StikDebug/StikJIT/Utilities/AppStoreIconFetcher.swift
2025-06-01 23:14:44 -04:00

31 lines
849 B
Swift

//
// IconsFetcher.swift
// Dont change the name of the actual file (it will break stuff)
// StikJIT
//
// Created by neoarz on 3/28/25.
//
import UIKit
class AppStoreIconFetcher {
private static var cache = [String: UIImage]()
private static let queue = DispatchQueue(label: "com.stik.StikJIT.iconFetchQueue", attributes: .concurrent)
static func getIcon(for bundleID: String, completion: @escaping (UIImage?) -> Void) {
if let icon = cache[bundleID] {
completion(icon)
return
}
queue.async {
let icon = try? JITEnableContext.shared.getAppIcon(withBundleId: bundleID)
DispatchQueue.main.async {
if let img = icon {
cache[bundleID] = img
}
completion(icon)
}
}
}
}