Я реализовал код, чтобы проверить, освобождает ли AVPlayer. К сожалению это не так. Я что-то пропустил?
func testPlayerDealloc() {
var player: AVPlayer? = AVPlayer()
weak var weakPlayer = player
weak var weakPlayerItem: AVPlayerItem?
let urlString = "http://csm-e.cds1.yospace.com/csm/extlive/yospace02,hlssample.m3u8"
if let player = player, let url = URL(string: urlString) {
let playerItem = AVPlayerItem(url: url)
weakPlayerItem = playerItem
player.replaceCurrentItem(with: playerItem)
}
player?.replaceCurrentItem(with: nil)
player = nil
XCTAssertNil(weakPlayer)
XCTAssertNil(weakPlayerItem)
}
В конце оба, strongPlayer и weakPlayerItem не равны nil.