mirror of
https://github.com/StikDebug/StikDebug.git
synced 2026-10-16 04:20:30 +00:00
31 lines
849 B
Swift
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)
|
|
}
|
|
}
|
|
}
|
|
}
|