Fix ContentViewModel deallocation

This commit is contained in:
Christoph Hagen 2022-06-24 12:05:07 +02:00
parent fac2e06967
commit 24d09d3883
2 changed files with 10 additions and 6 deletions

View File

@ -8,15 +8,17 @@ class ContentViewModel: ObservableObject {
@Published var frame: CGImage?
@Published var image: UIImage?
private let context = CIContext()
private let cameraManager = CameraManager.shared
private let frameManager = FrameManager.shared
private var cameraManager: CameraManager {
.shared
}
private var frameManager: FrameManager {
.shared
}
init() {
setupSubscriptions()
}
func setupSubscriptions() {
frameManager.image = nil
frameManager.current = nil
@ -34,7 +36,7 @@ class ContentViewModel: ObservableObject {
}
let ciImage = CIImage(cgImage: image)
return self.context.createCGImage(ciImage, from: ciImage.extent)
return FrameManager.shared.context.createCGImage(ciImage, from: ciImage.extent)
}
.assign(to: &$frame)

View File

@ -5,6 +5,8 @@ import UIKit
class FrameManager: NSObject, ObservableObject {
static let shared = FrameManager()
let context = CIContext()
@Published var current: CVPixelBuffer?