Tutorial by Examples

Key Value Coding is integrated into NSObject using NSKeyValueCoding protocol. What this means? It means that any id object is capable of calling valueForKey method and its various variants like valueForKeyPath etc. ' It also means that any id object can invoke setValue method and its various vari...
Setting up key value observing. In this case, we want to observe the contentOffset on an object that our observer owns // // Class to observe // @interface XYZScrollView: NSObject @property (nonatomic, assign) CGPoint contentOffset; @end @implementation XYZScrollView @end // // Clas...
if ([[dataObject objectForKey:@"yourVariable"] isEqualToString:"Hello World"]) { return YES; } else { return NO; } You can query values stored using KVC quickly and easily, without needing to retrieve or cast these as local variables.
Collection Operators can be used in a KVC key path to perform an operation on a “collection-type” property (i.e. NSArray, NSSet and similar). For example, a common operation to perform is to count the objects in a collection. To achieve this, you use the @count collection operator: self.array = @[@...

Page 1 of 1