The below code works, but I'm trying to come up with some math logic and use some binary
operator to put in place of this if statement
.
NSInteger indexCor = 0;
for (PFObject *object in self.objects) {
if (object == custom) {
if (indexCor < 2) {
NSLog(@"rodou indexCor <=2.");
[self.coresConjugadosDict setObject:self.uiColorsArray[0] forKey:object.objectId];
indexCor++;
}
else if (indexCor < 4) {
[self.coresConjugadosDict setObject:self.uiColorsArray[1] forKey:object.objectId];
indexCor++;
}
else if (indexCor < 6) {
[self.coresConjugadosDict setObject:self.uiColorsArray[2] forKey:object.objectId];
indexCor++;
}
else if (indexCor < 8) {
[self.coresConjugadosDict setObject:self.uiColorsArray[3] forKey:object.objectId];
indexCor++;
}
else if (indexCor < 10) {
[self.coresConjugadosDict setObject:self.uiColorsArray[4] forKey:object.objectId];
indexCor++;
}
else if (indexCor < 12) {
[self.coresConjugadosDict setObject:self.uiColorsArray[5] forKey:object.objectId];
indexCor++;
}
else {
[self.coresConjugadosDict setObject:self.uiColorsArray[6] forKey:object.objectId];
indexCor++;
}
}
So basically, some objects are going to be combined with another object. What I need to do is to set one UIColor
for each group of two combined objects. I have a NSArray
with the UIColors
I want to use, and right now, what happens is that each object that meets the specific criteria I add the first color in the array
, increment it. This way, each group of two objects will be of a different color.
So, if have 6 objects...
Objects 1,2 = Color 1 Objects 3,4 = Color 2 Objects 5,6 = Color 3
and so on.
I would like to achieve this without the if statement
.