Soheil Novinfard Soheil Novinfard - 1 year ago 136
iOS Question

max value of string in realm

I intended to get the max value of

string
type in
Realm
by
maxOfProperty
method as follows:

[[MyRealmObject allObjects] maxOfProperty:propertyName]


However, I encountered the following error:


maxProperty is not supported for string property


Considering I can't change the type of property, what should I do now?

Answer Source

We can use this solution

[[[[MyRealmObject allObjects] sortedResultsUsingKeyPath:propertyName ascending:NO] firstObject] objectForKeyedSubscript:propertyName];
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download