KVO for manually implemented properties

According to KVC Compliance ,

For properties that are an attribute or a relation to one, this requires that your class:

  • Inject a method named -<key>, -is<Key>or have an instance variable <key>or _<key>.

What is the best way to add observers to the FAKE properties, for example the following:

@property (nonatomic, readonly) BOOL shortlisted; 

#pragma mark - Fake properties

- (BOOL)shortlisted
{
    return [self.provider isJobShortlisted:self];
}   
+5
source share
1 answer

Dependent Keys

If you have only one key, which depends on another key of the same object, you can override +keyPathsForValuesAffectingValueForKey:. (See also this article for a common mistake.)

KVO , , , , , OS X ( iOS).

, KVO . ( ):

+12

All Articles