How to override getter for KVO compatible property?
1 answer
Nothing fancy as the synthesized properties meet the KVC and KVO requirements:
Property:
@property (nonatomic, readwrite, getter=isReady) BOOL ready;`
Implementation:
@synthesize ready;
- (BOOL) isReady {
// your custom logic here.
}
For a subclass, the NSOperation
KVO notifications for these properties will be automatic. You don't need to do anything (you don't need to call will / didSetValueForKey). If the behavior of attributes NSOperation
like isReady
or isFinished
depends on other properties or key paths, be sure to register them with KVO:
+ (NSSet *) keyPathsForValuesAffectingIsFinished {
NSSet *result = [NSSet setWithObject:@"finished"];
return result;
}
+1
source to share