Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Chirone

macrumors 6502
Original poster
Mar 2, 2009
279
0
NZ
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:
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
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.