Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

iOS Build a Blog Reader iPhone App Exploring the Master-Detail Template Modifying The Master-Detail Template

Andy Hanuman
Andy Hanuman
1,435 Points

Greetings Can somebody help me Create Sections In Master-Detail Application Xcode. This what i have in Xcode.

  • (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { return 11; }

  • (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { return self.Engines.count; }

  • (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"Cell" forIndexPath:indexPath];

    NSString *object = self.Engines[indexPath.row]; cell.textLabel.text = [object description]; return cell; }

  • (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath {

1 Answer

Andy,

Did you implement the method titleForHeaderInSection in you view controller class? You also need to make sure that you correctly set the numberOfRowsInSection value as well.

- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section
{
    NSString* title = nil;

    if (section == 0) {
        title = @"section 1";
    }
    else if (section == 1)
    {
        title = @"section 2";
    }
    else if (section == 2)
    {
        title = @"section 3";
    }

    return title;
}