I seem to have all these odd problems that I am struggling to find the answer for, this one seems so basic. I have a Table view that loads when the user clicks a button. I then iterate through the dollar amounts stoered in the mutableArray and add up the amounts for a total, but the math is off?
I think it has something to do with the dequeueReusableCellWithIdentifier since the final 2 that are supposed to be added to the total are skipped. I had a problem many months ago when values when off the screen they returned as 0, but I solved that. But in this instance I an just dealing with the array and the values in it's indexes?
Here is the print out from the NSLog. It adds everything up and then stops at 2300.00 at "Temp 8" and on? Thje values are there but it is not adding them in?
I think it has something to do with the dequeueReusableCellWithIdentifier since the final 2 that are supposed to be added to the total are skipped. I had a problem many months ago when values when off the screen they returned as 0, but I solved that. But in this instance I an just dealing with the array and the values in it's indexes?
Code:
-(void)addUpTheValues{ // calculates the values in the text fields
runningGrandTotal = 0.0;
for (int i = 0; i < totalPayments.count; i++) {
NSString *TempTwoString = [totalPayments objectAtIndex:i];
runningGrandTotal += [TempTwoString floatValue];
NSLog(@"Temp %d : %@", i, TempTwoString);
NSLog(@"The Running Grand Total is %.2f", runningGrandTotal);
}
grandTotal.text = [NSString stringWithFormat:@"%.2f",runningGrandTotal];
}
Here is the print out from the NSLog. It adds everything up and then stops at 2300.00 at "Temp 8" and on? Thje values are there but it is not adding them in?
2011-11-23 13:50:38.858 Money List[4679:607] Temp 0 : 400.00
2011-11-23 13:50:38.860 Money List[4679:607] The Running Grand Total is 400.00
2011-11-23 13:50:38.863 Money List[4679:607] Temp 1 : 200.00
2011-11-23 13:50:38.865 Money List[4679:607] The Running Grand Total is 600.00
2011-11-23 13:50:38.867 Money List[4679:607] Temp 2 : 800.00
2011-11-23 13:50:38.869 Money List[4679:607] The Running Grand Total is 1400.00
2011-11-23 13:50:38.870 Money List[4679:607] Temp 3 : 100.00
2011-11-23 13:50:38.872 Money List[4679:607] The Running Grand Total is 1500.00
2011-11-23 13:50:38.873 Money List[4679:607] Temp 4 : 200.00
2011-11-23 13:50:38.882 Money List[4679:607] The Running Grand Total is 1700.00
2011-11-23 13:50:38.884 Money List[4679:607] Temp 5 : 200.00
2011-11-23 13:50:38.885 Money List[4679:607] The Running Grand Total is 1900.00
2011-11-23 13:50:38.887 Money List[4679:607] Temp 6 : 200.00
2011-11-23 13:50:38.889 Money List[4679:607] The Running Grand Total is 2100.00
2011-11-23 13:50:38.890 Money List[4679:607] Temp 7 : 200.00
2011-11-23 13:50:38.896 Money List[4679:607] The Running Grand Total is 2300.00
2011-11-23 13:50:38.899 Money List[4679:607] Temp 8 : $400.00
2011-11-23 13:50:38.903 Money List[4679:607] The Running Grand Total is 2300.00
2011-11-23 13:50:38.906 Money List[4679:607] Temp 9 : $750.00
2011-11-23 13:50:38.909 Money List[4679:607] The Running Grand Total is 2300.00