cocoa - KVO problem "Cannot remove an observer" -
I have a NSARE controller connected to a core data object, which is set to the AutoRARGE content and is filtered by Fredett. OK, until I try to finish a relationship and hand it over to another. At that time, my app crashes and I get the following error:
The main route from the object can not remove a supervisor for "career.type", most likely because the key "Validity for Career" is being sent without proper KVO notification, check the KVO compliance of the individual category.
By looking around, it seems that my NSArrayController is the reason for this problem by being automatically set to rearranged content. But I'm trying to solve the problem without resorting to rearranging the NSArrayController manually. Here is the pseudo code that is triggering the error:
object.career = nil; Object.field = (field *) item;
Here is a bill using my NSArrayController:
(Career! = Zero & carrier ==% @) || (Field! = Zero & amp; field ==% @)
Where there is a core data object for both instances.
Actually, it seems that the NSArrayController has a supervisor set for the object.career.type and due to terminating the relationship, that supervisor is automatically removed. So I am thinking that I am going wrong about this? Am I receiving a copy of the object, removing it from the MOC and re-inserting it according to the Nile and field set with the carrier?
How do I properly inform the supervisor that the type has been canceled? Note that use all the properties and relationships mentioned here is Vanilla KVO-compatible Greater / Sets.
Faults and KVO notifications
When the core data changes an object in some error, key-value overview (KVO) change notifications (see Key-Value Overview Programming Guide) sent for the properties of the object, if you are looking at the properties of that object Has turned into a mistake and the mistake has been realized, then you receive change information for those qualities whose values In reality, there has not been any change.
Although the verses from the value are not changing from your perspective, the literal bytes in memory are changing because the size of the object has decreased. In the key-value observational mechanism, the core data is required to issue information, whenever the indicator changes according to the value, compared to the indicator. KVO requires these notifications to track changes in all major paths and dependent objects.
So basically you will receive a notification, in which you will be told that there is no change here, even if it does not happen. So you found out whether the item has become a mistake or not. Then remove the old supervisor and add new one in the same way ...
This work for me (sample code):
- (Zero) Inspection Volume: (NSString *) The object of the pipe: (ID) object change: (NSDictionary *) References: Change (Zero *) Reference {[Super Inspection ValueFrenchPath: Keypages of Object: Object Changes: Change Reference: Context]; If ([keypath is avaltostring: @ "page index"]) {// Basically remove observer from fault object and assign new if ([object is fault]) {[Object object Observer: Self-pharmacopath: @ "Page Index "]; [The_current_instance_returned_by_core_data addObserver: for self-path: keypath option: NSKeyValueObservingOptionOld reference: NULL]; } // Whatever you want to do on the change ...}}
Comments
Post a Comment