I have a class that has 4 integer properties. I have separate methods to compare one integer property to another instance. The comparison logic is the same for all integer properties. Is there a method or way I don't know how to one line selector different properties?
//Current sudo code compare
- (BOOL)compare1:otherInstance
{
if (self.number1 == otherInstance.number2) return YES;
else return NO;
}
- (BOOL)compare2:otherInstance
{
if (self.number2 == otherInstance.number2) return YES;
else return NO;
}
//Ideal way sudo code compare
- (BOOL)compare:otherInstance useProp:prop
{
if ([self selectProp:prop] == [otherInstance selectProp:prop]) return YES;
else return NO;
}
I can write my own little property select, but will prefer to use anything provided by objective c. The comparison is more complicated than the sudo code, just showing the part that for my question