Core data, reacting to a change in the interface

Discussion in 'Mac Programming' started by Chirone, May 25, 2009.

  1. macrumors 6502

    Joined:
    Mar 2, 2009
    Location:
    NZ
    #1
    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:

    Code:
    -(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:
    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
     

Share This Page