Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to show the sum of values as a "Title" for each section in a grouped UITableView?
    text
    copied!<p>Each section in my table consists of one or more cells that contain a number. I would like to show the sum of the numbers as part of each section title.</p> <p>For example:</p> <pre><code>section title: The following sum is: 32 3 5 7 8 9 section title: The following sum is: 20 2 4 6 8 </code></pre> <p>My question is, "where do I perform the tally for each section and how do I access just the cells from each section? i.e. which delegate function, etc... so that the tally is ready for me to display here in this routine?</p> <p>Thank you.</p> <p>Here is my current <strong>TitleForHeaderInSection</strong> delegate function.</p> <pre><code>- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section { id &lt;NSFetchedResultsSectionInfo&gt; sectionInfo = [[_fetchedResultsController sections] objectAtIndex:section]; return [sectionInfo name]; } </code></pre> <p>UPDATE:</p> <p>Here is the code that pulls each cell's content from the fetchedresultscontroller and places it in the cell.</p> <pre><code>- (void)configureCell:(UITableViewCell *)cell atIndexPath:(NSIndexPath *)indexPath { Grade *sGrade = [_fetchedResultsController objectAtIndexPath:indexPath]; float averageScore, _score, _total; _score = [sGrade.scoreValue floatValue]; _total = [sGrade.scorePossible floatValue]; averageScore = (_score / _total) * 100; cell.textLabel.text = [NSString stringWithFormat: @"%2.2f%% - (%@ of %@)", averageScore, [sGrade.scoreValue stringValue], [sGrade.scorePossible stringValue]]; cell.detailTextLabel.text = [sGrade commentInfo]; } </code></pre> <p>So in reality, each of my cells look something like this: 87.00% - (87 / 100). And so if I have 8 quiz scores like this in the "quizzes" section, then I want to show the average score for all quizzes as part of the title for that section in the grouped UITable.</p>
 

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