I am working with the Master-Detail Application template. I hard coded an NSArray to set the text label:
groups = [[NSArray alloc] initWithObjects:@"Group1", @"Group2", nil];
Then I created two arrays of five words each and put those two arrays into another array:
group1 = [[NSArray alloc] initWithObjects:@"A", @"and", @"find", @"go", @"have", nil];
group2 = [[NSArray alloc] initWithObjects:@"here", @"jump", @"not", @"on", @"one", nil];
groupWords = [[NSArray alloc] initWithObjects:group1, group2, nil];
In the tableView:cellForRowAtIndexPath: I am trying to set the cells with the text as "Group#" and the detail text to be the list of words. I am able to set the text label for each cell but I can't seem to figure out how to pass the array of strings to set each detail text label.
Example:
Group 1
A, and, find, go, have
Group 2
here, jump, not, on, one
Here is what I have so far:
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier];
}
cell.textLabel.text = [groups objectAtIndex:[indexPath row]];
NSString *detailWords = [self.groupWords objectAtIndex:[indexPath row]];
NSLog(@"%@", detailWords);
cell.detailTextLabel.text =
return cell;
Any help is very much appreciated.