I am observing a core data value with KVO, but when I remove the observer, I get the message:
Cannot remove an observer for the key path "flightname.value" from because it is not registered as an observer.
Code below called two times. First time _selectedFlight is null, so removeObserver is not triggered. Second time I want to remove, what first time was assigned. Observer address is not changing.
//Remove old binding.
if (_selectedFlight) {
id oi = [_selectedFlight observationInfo];
if (![oi isFault]) {
//NOTE: In somehow I cant remove it.
[_selectedFlight removeObserver:self forKeyPath:@"flightname.value"];
}
}
_selectedFlight = [_selectedRegistration.flights objectAtIndex:(_selectedRegistration.flights.count - indexPath.row - 1)];
//Bind flightname to the Summary View.
[_selectedFlight addObserver:self forKeyPath:@"flightname.value" options:0 context:NULL];
Here you can see the content of the observationInfo and some details before removeObserver is called.:
(lldb) po oi (id) $1 = 0x06b42d80 ( Context: 0x0, Property: 0x6b425e0> )
(lldb) po self (MenuViewController *const) $2 = 0x08136f90
(lldb) po _selectedFlight (Flight *) $3 = 0x06b26770 (entity: Flight; id: 0x6b26ef0 ; data: { date = "0x6b1b8f0 "; destination = "0x6b29140 "; flightname = "0x6b29150 "; id = 1; ladc = nil; loadsheet = nil; origin = "0x6b29160 "; registration = "0x6e60700 "; sta = "0xc81fb90 "; std = "0xc8203d0 "; todc = "0x6b293e0 "; })