Search code examples
iosswiftavplayeravplayeritem

How to set AVPlayerItem to nil when observer does not complete


I add a observer named 'status' into AVPlayerItem. Send the observer then set AVPlayerItem to nil when the observer does not complete

I have remove the observer when dealloc AVPlayerItem

Get the following error:

NSInternalInconsistencyException', reason: 'An instance 0x7dc5e7d0 of class AVPlayerItem was deallocated while key value observers were still registered with it. Current observation info: ( Context: 0x0, Property: 0x7b8ad140>


Solution

  • It caused initial the avplayeritem by async