In iOS, calculate the maximum and minimum numbers of array elements, and in ios Array
I used to calculate the maximum and minimum values of a number in the array. I was very drunk after seeing this method.
NSArray * testArray = [NSArray arrayWithObjects: @ "-2.0", @ "2.3", @ "3.0", @ "4.0", nil];
NSNumber * sum = [testArray valueForKeyPath: @ "@ sum. floatValue"];
NSNumber * avg = [testArray valueForKeyPath: @ "@ avg. floatValue"];
NSNumber * max = [testArray valueForKeyPath: @ "@ max. floatValue"];
NSNumber * min = [testArray valueForKeyPath: @ "@ min. floatValue"];
A positive number or a negative number.
For valueForKeyPath: how is this method going on, I will provide some additional instructions later.
Copyright Disclaimer: This article is an original article by the blogger and cannot be reproduced without the permission of the blogger.