I have an NSArray filled with 200,000 words and I don't know the length of each word. I need to know what is the maximum length of a word contained in that array.
For example, if my array is {"dog","person","amazing"} The maximum length of a word contained in this array would be 7 ("amazing")
How would I do this?
Besides all methods that imply iterating over the array, you can easily do this with valueForKeyPath:
, using the @max
collection operator:
NSNumber* maxLength= [array valueForKeyPath: @"@max.length"];
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With