Note that there are some explanatory texts on larger screens.

plurals
  1. POValue in the last row of the uitableview changing
    text
    copied!<p>I am having an UITableView where i have labels in each row with a float value. and the last the label in the last row should display the total Amount.</p> <p>its showing the total amount fine but if the tableView is scrolled offscreen and returned the amount is getting increased.</p> <pre><code> if(tableView == self.allTab) { if(indexPath.section == 0) { self.firstLabel.text = @"Category"; self.firstLabel.textColor = [UIColor redColor]; self.secondLabel.text = @"Date"; self.secondLabel.textColor = [UIColor redColor]; self.thirdLabel.text = @"Amount"; self.thirdLabel.textColor = [UIColor redColor]; } else if(indexPath.section == 1) { NSManagedObject *records = nil; records = [self.listOfExpenses objectAtIndex:indexPath.row]; self.firstLabel.text = [records valueForKey:@"category"]; NSString *dateString = [NSString stringWithFormat:@"%@",[records valueForKey:@"date"]]; NSString *dateWithInitialFormat = dateString; NSDateFormatter *dateFormatter = [[NSDateFormatter alloc]init]; [dateFormatter setDateFormat:@"yyyy-MM-dd HH:mm:ss Z"]; NSDate *date = [dateFormatter dateFromString:dateWithInitialFormat]; [dateFormatter setDateStyle:NSDateFormatterMediumStyle]; NSString *dateWithNewFormat = [dateFormatter stringFromDate:date]; self.secondLabel.text = dateWithNewFormat; NSString *amountString = [NSString stringWithFormat:@"%@",[records valueForKey:@"amount"]]; self.thirdLabel.text = amountString; totalAmount = totalAmount + [amountString doubleValue]; } else if(indexPath.section == 2) { self.firstLabel.text = @"Total"; self.firstLabel.textColor = [UIColor redColor]; self.thirdLabel.text = [NSString stringWithFormat:@"%.2f",totalAmount]; self.thirdLabel.textColor = [UIColor redColor]; self.thirdLabel.adjustsFontSizeToFitWidth = YES; } } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload