How to find largest value from array of NSDictionary objects?

Sachin Kumaram

How to find largest value from NSArray of NSDictionary?

Here is my code,

NSDictionary *d1 = [NSDictionary dictionaryWithObject:[NSNumber numberWithInt:35] forKey:@"data"];
NSDictionary *d2 = [NSDictionary dictionaryWithObject:[NSNumber numberWithInt:52] forKey:@"data"];

NSArray *array = [NSArray arrayWithObjects:d1, d2, nil];
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"SELF.data == %@[email protected]", array];

However this sometimes gives wrong results. Am I missing anything?

malex

Try this way for NSNumber values

NSNumber *max = [array valueForKeyPath:@"@max.data"];

and

NSNumber *max = [array valueForKeyPath:@"@max.data.floatValue"];

for NSString/NSNumbers mixed values.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

How to find array index of largest value?

From Dev

Find second largest value in array

From Dev

Get object from array with NSDictionary objects

From Dev

How to find the 100th largest number from an array

From Dev

How to find the 100th largest number from an array

From Dev

How can i find the largest gameobject size from array?

From Dev

How to find the Largest Difference in an Array

From Dev

Find value in array of objects

From Dev

Find the largest value for an array of hashes with common keys?

From Dev

Find the smallest and largest value in an array with JavaScript

From Java

how to search a value from a array of objects inside array of objects?

From Dev

How to filter NSDictionary by value and create new NSDictionary from that?

From Dev

How to access a value from an array of objects in localStorange

From Dev

How to extract a value from an Array of objects

From Dev

How to get the value from a nested array with objects

From Dev

Java, Finding Kth largest value from the array

From Dev

How to find the largest element of an array of known size?

From Dev

Best way to find smallest value from array containing objects

From Dev

How to get key/value pair from NSDictionary?

From Dev

How to get JSON value from NSDictionary

From Dev

How to get key and value from an NSDictionary?

From Dev

how to get key of selected value from nsdictionary

From Dev

How to get the value for key @int from NSDictionary?

From Dev

How get a value from NSDictionary and move it to an NSArray

From Dev

How to find the 2nd largest number in the array, but return the last index that the value appears in?

From Dev

How to find objects from first array in second array? Swift iOS

From Java

Find a value in an array of objects in Javascript

From Dev

javascript How to get an objects value from an array full of objects?

From Dev

Given an array of integers, find out the third largest value in the array

Related Related

  1. 1

    How to find array index of largest value?

  2. 2

    Find second largest value in array

  3. 3

    Get object from array with NSDictionary objects

  4. 4

    How to find the 100th largest number from an array

  5. 5

    How to find the 100th largest number from an array

  6. 6

    How can i find the largest gameobject size from array?

  7. 7

    How to find the Largest Difference in an Array

  8. 8

    Find value in array of objects

  9. 9

    Find the largest value for an array of hashes with common keys?

  10. 10

    Find the smallest and largest value in an array with JavaScript

  11. 11

    how to search a value from a array of objects inside array of objects?

  12. 12

    How to filter NSDictionary by value and create new NSDictionary from that?

  13. 13

    How to access a value from an array of objects in localStorange

  14. 14

    How to extract a value from an Array of objects

  15. 15

    How to get the value from a nested array with objects

  16. 16

    Java, Finding Kth largest value from the array

  17. 17

    How to find the largest element of an array of known size?

  18. 18

    Best way to find smallest value from array containing objects

  19. 19

    How to get key/value pair from NSDictionary?

  20. 20

    How to get JSON value from NSDictionary

  21. 21

    How to get key and value from an NSDictionary?

  22. 22

    how to get key of selected value from nsdictionary

  23. 23

    How to get the value for key @int from NSDictionary?

  24. 24

    How get a value from NSDictionary and move it to an NSArray

  25. 25

    How to find the 2nd largest number in the array, but return the last index that the value appears in?

  26. 26

    How to find objects from first array in second array? Swift iOS

  27. 27

    Find a value in an array of objects in Javascript

  28. 28

    javascript How to get an objects value from an array full of objects?

  29. 29

    Given an array of integers, find out the third largest value in the array

HotTag

Archive