Return the name of the class instance with the highest 'someValue' instance variable

Posted by Timbo on Stack Overflow See other posts from Stack Overflow or by Timbo
Published on 2010-05-25T05:40:44Z Indexed on 2010/05/25 6:11 UTC
Read the original article Hit count: 259

Filed under:
|

I have a brand new Objective-C class called test. The test class has an instance variable called someValue, which contains an integer.

I create 5 instances of the test class called aTest, bTest, cTest, dTest and eTest. The appropriate synthesize and property declarations for someValue are in place.

Is there a clean way of returning the name of the class instance with the highest someValue value out of all the existing test class instances? The number of class instances may vary from the 5 in my example.

Note I don't care what the value is, I just want to return the name of the class instance with the highest 'someValue' instance variable.

I've tried a few NSMutable arrays however can only get the value not the name of the variable that contains it.

Thanks in advance

© Stack Overflow or respective owner

Related posts about iphone

Related posts about objective-c