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 Getting Data from the Web What is NSDictionary?

Alfonso Lagrasta
Alfonso Lagrasta
7,551 Points

No subtitles - IOS7

Hi all, I'm following closely the instructions in the video but no subtitles are shown. I've tried to implement them programmatically with UITableViewCellStyleSubtile constant but nothing happens. Can you help me? My code is the following:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath;
{


    static NSString *CellIdentifier = @"Cell";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"Cell" forIndexPath:indexPath];


    //if (cell == nil) {
        //cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier];
    //}

    NSDictionary *blogposts1 =[self.blogposts objectAtIndex:indexPath.row];
    //NSDictionary *blogposts2 =[self.Development objectAtIndex:indexPath.row];
    //NSDictionary *blogposts3 = [self.Design objectAtIndex:indexPath.row];//


     //if (indexPath.section == 0) {

        cell.textLabel.text = [blogposts1 valueForKey:@"title"];
        cell.detailTextLabel.text = [blogposts1 valueForKey:@"author"];
    //}

     //else if (indexPath.section == 1){

        //cell.textLabel.text = [blogposts2 valueForKey:@"title"];
        //cell.detailTextLabel.text = [blogposts2 valueForKey:@"author"];
    //}

    //else if (indexPath.section == 2){
        //cell.textLabel.text = [blogposts3 valueForKey:@"title"];
        //cell.detailTextLabel.text = [blogposts3 valueForKey:@"author"];
    //}

    return cell;

}

Amit Bijlani

2 Answers

Kevin Hamil
Kevin Hamil
8,203 Points

I am just looking on my phone, but right away I see at the end of your first line you are ending the declaration with a semi-colon before the opening curly brace.

this...

indexPath; {

should be

indexPath {

I can double check when I get to my computer in a min.

Alfonso Lagrasta
Alfonso Lagrasta
7,551 Points

Thanks Kevin, I've tried to delete the semi colon, still no subtitles. Before this change the code ran correctly it only showed titles but no subtitles. I implemented the cell in the main storyboard as shown in the video, selecting the 'subtitle' option in style, still nothing.

Kevin Hamil
Kevin Hamil
8,203 Points

Yeah that was just a guess after looking at it so quickly...

I'm fairly new to the iOS track and Obj-C in general, but it seems to me like we would need to see more of your code other than just that UITableViewCell block since it's dependent on previous code. I have progressed beyond this point in the track so I don't have example code in front of me anymore.

To identify the source, we would need to see all related code. For example, we can't see what blogposts is in your NSDictionary value... maybe there's an issue there, prior to this.

That's just my 2 cents... someone else with more experience and understanding can chime in.

Alfonso Lagrasta
Alfonso Lagrasta
7,551 Points

Thanks man I appreciate your help, I'll try to post the entire code as soon as I can so you can check it out.