ios – How do I save instance of my custom object to fileManager in swift?


I have a struct CustomContainer which I need to save to fileManager. The Problem is that struct contains AVPlayer & AVPlayerItem and I can’t figure out how to handle those. The structure of the code is in such a way that I can’t keep these AV items out of the struct. I am able to cache them but can’t seem to save them in fileManager.

   class CustomContainer {
    
    var url: String
    var reset: Bool = false {
        didSet {
            if reset {
                player.pause()
                player.seek(to: .zero)
            }
        }
    }
    let player: AVPlayer
    let playerItem: AVPlayerItem
    init(player: AVPlayer, item: AVPlayerItem, url: String) {
        self.player = player
        self.playerItem = item
        self.url = url
    }
}

Any help would be appreciated!

Latest articles

spot_imgspot_img

Related articles

Leave a reply

Please enter your comment!
Please enter your name here

spot_imgspot_img