Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You need more complex storage for your data. You can make array of dictionaries to describe all chapter's data.</p> <pre><code>- (void)viewDidLoad { chapterList = [[NSMutableArray alloc] init]; ... chapterInfo = [NSDictionary dictionaryWithObjectsAndKeys:@"Chapter 9", @"title", [NSNumber numberWithInt:18], @"numberOfVerses", nil]; [chapterList addObject:chapterInfo]; chapterInfo = [NSDictionary dictionaryWithObjectsAndKeys:@"Chapter 10", @"title", [NSNumber numberWithInt:72], @"numberOfVerses", nil]; [chapterList addObject:chapterInfo]; ... } - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *CellIdentifier = @"Cell"; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; if (cell == nil) { cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease]; } NSDictionary *chapterInfo = [chapterList objectAtIndex:indexPath.row]; cell.textLabel.text = [chapterInfo objectForKey:@"title"]; return cell; } - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { VersesViewController *detailViewController = [[VersesViewController alloc] initWithNibName:@"VersesViewController" bundle:nil]; NSDictionary *chapterInfo = [chapterList objectAtIndex:indexPath.row]; [detailViewController setNumberOfVerses:[[chapterInfo objectForKey:@"numberOfVerses"] intValue]]; [self.navigationController pushViewController:detailViewController animated:YES]; [detailViewController release]; } </code></pre> <p>The best would be to create plist file with description of all chapters and then load it like this:</p> <pre><code>NSString *path = [[NSBundle mainBundle] pathForResource:@"chapters" ofType:@"plist"]; NSArray *chaptersList = [[NSArray alloc] initWithContentsOfFile:path]; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

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