I need to write a custom setter method for a field (we\'ll call it foo) in my subclass of NSManagedObject. foo is defined in the data
Here is the Apple way for overriding NSManagedObject properties (without breaking KVO), in your .m file:
@interface Transaction (DynamicAccessors)
- (void)managedObjectOriginal_setDate:(NSDate *)date;
@end
@implementation Transaction
@dynamic date;
- (void)setDate:(NSDate *)date
{
// invoke the dynamic implementation of setDate (calls the willChange/didChange for you)
[self managedObjectOriginal_setDate:(NSString *)date;
// your custom code
}
managedObjectOriginal_propertyName is a built-in magic method you just have to add the definition for. As seen at bottom of this page What's New in Core Data in macOS 10.12, iOS 10.0, tvOS 10.0, and watchOS 3.0