Created
December 8, 2016 20:35
-
-
Save petermolnar-dev/f3b0f12ba565d3b3ef2aa4cd005008a3 to your computer and use it in GitHub Desktop.
Key-Value Coding Aggregates on collection
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
NSArray *numbers = @[@6,@4,@7,@90]; | |
NSNumber *maxNumber = [numbers valueForKeyPath:@"@max.self"]; | |
NSNumber *minNumber = [numbers valueForKeyPath:@"@min.self"]; | |
NSNumber *sumOfNumbers = [numbers valueForKeyPath:@"@sum.self"]; | |
NSNumber *avgOfNumbers = [numbers valueForKeyPath:@"@avg.self"]; | |
NSLog(@"\nmin: %@\nmax: %@\nsum: %@\navg: %@", minNumber, maxNumber, sumOfNumbers, avgOfNumbers); | |
NSDate *today = [NSDate date]; | |
NSArray *dates = @[today, | |
[today dateByAddingTimeInterval: -86400.0], | |
[today dateByAddingTimeInterval: 86400.0] | |
]; | |
NSDate *maxDate = [dates valueForKeyPath:@"@max.self"]; | |
NSDate *minDate = [dates valueForKeyPath:@"@min.self"]; | |
NSLog(@"\nminDate: %@\nmaxDate: %@\n", maxDate, minDate); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment