Quantcast
Channel: Recent Threads — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 204402

AddObserver and Dispose problem

$
0
0

I would like to observe an AVPlayerItem instance, but when I am trying to dispose the observer an exception is thrown:

Objective-C exception thrown. Name: NSRangeException Reason: Cannot remove an observer <__XamarinObjectObserver 0x1cb7ad90> for the key path "error" from <__XamarinObjectObserver 0x1cb7ad90> because it is not registered as an observer.

Code:

        this.sound = AVPlayerItem.FromUrl(url);
        this.soundErrorObserver = this.sound.AddObserver("error", NSKeyValueObservingOptions.New, this.OnErrorDetected);

        [...]

        this.soundErrorObserver.Dispose();
        this.soundErrorObserver = null;
        this.sound.Dispose();
        this.sound = null;

Am I doing something wrong?


Viewing all articles
Browse latest Browse all 204402

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>