PDA

View Full Version : Core data, reacting to a change in the interface




Chirone
May 25, 2009, 05:02 PM
when using core data there is a text field that sets a value for an entity's string property.

when this property is changed i want a whole bunch of things to change when depending on what that string was.

what i did was (what i think) override the setPropertyOne and getPropertyOne methods (where propertyOne is the string property of the class)

using the core data utility tutorial as a guide i typed something like this:

-(NSString*)propertyOne {
[self willAccessValueForKey: @"propertyOne"];
NSString* s = propertyOne;
[self didAccessValueForKey: @"propertyOne"];
return s;
}
-(void)setPropertyOne: (NSString*)newPropertyOne {

[self willChangeValueForKey: @"propertyOne"];
propertyOne = newPropertyOne;
[self didChangeValueForKey: @"propertyOne"];


now this all works fine... other than the point where i undo and redo
undo works fine, changing propertyOne back to the prior string works... redo breaks
it breaks with this being printed out to the console:
2009-05-26 09:50:04.250 CoreAnimWithData 003[47763:10b] *** -[_NSUndoBeginMark copyWithZone:]: unrecognized selector sent to instance 0x171380

also when i added code to make new entityTwo instances and add them to the set that carries those instances undo would work fine, but if i did that then the program would crash without saying anything when i went to add a new instance of entityOne