I have a custom tableViewCell in which one label present in each cells
so I have to calculate labels value and show the total in other label which is present in the same view
please any one suggest me what I do?"
I have a custom tableViewCell in which one label present in each cells
so I have to calculate labels value and show the total in other label which is present in the same view
please any one suggest me what I do?"
You must have been setting your label values from some array or dictionary. Then just get the values from your array/ dictionary and add them then in
tableView(tableView: UITableView!, cellForRowAtIndexPath indexPath: NSIndexPath?) -> UITableViewCell?
Compare current indexPath.row with your needed indexPath.row which may be at the last(i.e, your array count) , and there set the label value accordingly.
First of all, you can't get all cells without scrolling them. You can only get first visible cells. So my suggestion is that get the total row count from the response and get the values from each label and add their value and show the total in another label.
For example:
NSMutableArray *responseArray=[[NSMutableArray alloc]initWithObjects:@"2",@"4",@"6",nil];
int count = 0;
for(int i=0;i<[responseArray count];i++)
{
count=count+[[responseArray objectAtIndex:i] intValue];
}
UILabel *lblTotalCount=[UILabel new];
lblTotalCount.text=[NSString stringWithFormat:@"%d",count];
NSLog(@"lblTotalCount.text-->%@",lblTotalCount.text);