In an effort to prevent multiple observers from being added, I'm removing the observer before I add one, which was recommended here: iPhone - testing if a notification exists.
[[self getPlayer] removeObserver:self forKeyPath:@"position"];
[[self getPlayer] addObserver:self forKeyPath:@"position" options:NSKeyValueObservingOptionNew context:nil];
However, doing so causes an exception: __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__
Any ideas on how to check if an observer already exists for a key path and if so not add a new one?
Add a boolean that keeps track of whether or not you've added your observer. Set it to true after adding, and only remove your observer if the flag indicates that you have added one.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With