Imagine I have a Core Data object, Product. Each Product has a quantity
, price
, and total
attribute. Total is there for efficiency when re
You should override the setter method for the quantity
attribute of your entity:
- (void)setQuantity:(NSNumber *)quantity
{
[self willChangeValueForKey:@"quantity"];
[self setPrimitiveValue:quantity forKey:@"quantity"];
[self didChangeValueForKey:@"quantity"];
NSNumber *price = ... // compute new price
self.price = price;
}
You can add that code to a category of the Product class if you don't want to change the Xcode generated files.