Fix ContentViewModel deallocation
This commit is contained in:
parent
fac2e06967
commit
24d09d3883
@ -8,10 +8,12 @@ class ContentViewModel: ObservableObject {
|
|||||||
@Published var frame: CGImage?
|
@Published var frame: CGImage?
|
||||||
@Published var image: UIImage?
|
@Published var image: UIImage?
|
||||||
|
|
||||||
private let context = CIContext()
|
private var cameraManager: CameraManager {
|
||||||
|
.shared
|
||||||
private let cameraManager = CameraManager.shared
|
}
|
||||||
private let frameManager = FrameManager.shared
|
private var frameManager: FrameManager {
|
||||||
|
.shared
|
||||||
|
}
|
||||||
|
|
||||||
init() {
|
init() {
|
||||||
setupSubscriptions()
|
setupSubscriptions()
|
||||||
@ -34,7 +36,7 @@ class ContentViewModel: ObservableObject {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let ciImage = CIImage(cgImage: image)
|
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)
|
.assign(to: &$frame)
|
||||||
|
|
||||||
|
@ -6,6 +6,8 @@ class FrameManager: NSObject, ObservableObject {
|
|||||||
|
|
||||||
static let shared = FrameManager()
|
static let shared = FrameManager()
|
||||||
|
|
||||||
|
let context = CIContext()
|
||||||
|
|
||||||
@Published var current: CVPixelBuffer?
|
@Published var current: CVPixelBuffer?
|
||||||
|
|
||||||
@Published var image: UIImage?
|
@Published var image: UIImage?
|
||||||
|
Loading…
Reference in New Issue
Block a user