fix(ios): store view as week reference in HybridVideoViewViewManager

This commit is contained in:
Krzysztof Moch
2024-11-27 15:59:16 +01:00
parent 69be802292
commit fa4098ae53
+12 -4
View File
@@ -9,23 +9,31 @@ import Foundation
import NitroModules
class HybridVideoViewViewManager: HybridVideoViewViewManagerSpec {
weak var view: VideoComponentView?
var player: (any HybridVideoPlayerSpec)? {
get {
view.player
guard let view = view else {
print("RN Video: VideoComponentView is no longer available. It is likely that the view was deallocated.")
return nil
}
return view.player
}
set {
guard let view = view else {
print("RN Video: VideoComponentView is no longer available. It is likely that the view was deallocated.")
return
}
view.player = newValue
}
}
let view: VideoComponentView
init(nitroId: Double) throws {
guard let view = VideoComponentView.globalViewsMap.object(forKey: NSNumber(value: nitroId)) else {
throw RuntimeError.error(withMessage: "No view found for \(nitroId)")
}
self.view = view
self.view = view
}
// Initialize HybridContext