I have an NSArray
of custom objects. Those objects have a property price
which I want to compare with the price
of all other objects in the array. If the price difference to another objects' price is less then 100, there should be a method call.
NSArray products (
{
name = "Product A";
price = "1299.50";
},
{
name = "Product B";
price = "999.90";
},
{
name = "Product C";
price = "1249.00";
},
{
name = "Product D";
price = "1899.50";
}
)
=> Product A and Product C have a price difference from < 100 and therefore a method closePrices:(NSArray *)objectsWhichAreClose
should be called passing the objects which are close.
I wonder which is the most efficient way to achieve this?