I have a data class:
@interface Car : NSObject
{
Engine *_engine;
}
//...
With the class:
@interface Engine : NSObject
{
NSInteger _power;
NSString *_name;
}
//...
And an array:
NSArray *myArray = [ // a bunch of Car objects with Engines
How would I make a new array that contains all unique items based on Engine 'power'?
For Example:
0 Car with Engine ( power = 20, name = "engine one" )
1 Car with Engine ( power = 45, name = "engine two" )
2 Car with Engine ( power = 20, name = "engine three" )
Final array would be car objects 0 and 1
Both data classes have accessors, e.g:
- (NSInteger)power;