How to calculate and pick the value from two diffrent array on a same loop?
something like that
eg:
for(UITextField *field in textFieldArray && textFieldArray2)
i have to subtract the value and i have 2 Array and i want to subtract the value of two textfield from different array but same index…
My code is
int result = 0;
for(UITextField *field in textFieldArray) // will iterate all UITextField which was added
{
result += [field.text intValue]; //or floatValue
}
NSLog(@"the result is %d", result); //here you have sum of all the text fields' text
i want to subtract this but both text fields are on different Array but have same index…
int y12 = ([Txt_New_Actual.text intValue]);
float c116 = y12-([Txt_New_Estimated.text floatValue]);
Txt_New_ONU.text = [[NSString alloc] initWithFormat:@"%.2f",c116];
Get the index of the current object in your fast enumeration loop, then use
indexOfObject:to get the index and use that withobjectAtIndex:on your second array.Something like this:
You should still put some kind of check into that code if the returned value from the 2nd array is valid.