NSArray数组通过kvc得到最大值

NSArray *allValues = @[ [NSNumber numberWithInt:20],
                        [NSNumber numberWithInt:36],
                        [NSNumber numberWithInt:84],
                        [NSNumber numberWithInt:11],
                        [NSNumber numberWithInt:28]];

int max = [[allValues valueForKeyPath:@"@max.intValue"] intValue];
int min = [[allValues valueForKeyPath:@"@min.intValue"] intValue];

 

你可能感兴趣的:(NSArray)