ios removing an observer before it exists raises exception

Viewed 7246

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?

1 Answers
Related