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 Downloading and Parsing JSON Data

Shaun Kelly
Shaun Kelly
5,648 Points

Information not being displayed on table view ?

- (void)viewDidLoad {
    [super viewDidLoad];


    NSURL *blogURL = [NSURL URLWithString:@"http://blog.teamtreehouse.com/api/get_recent_summary/"];

    NSData *jsonData = [NSData dataWithContentsOfURL:blogURL];




    NSError *error = nil;


    NSDictionary *dataDictionary = [NSJSONSerialization JSONObjectWithData:jsonData options:0 error:&error];


    self.blogPosts = [dataDictionary objectForKey:@"posts"];


}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

#pragma mark - Table view data source

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    // Return the number of sections.
    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    // Return the number of rows in the section.
    return [self.blogPosts count];
}


- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    //creating a cell object that can be reused
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"Cell" forIndexPath:indexPath];

  //creating a NSDicationary object for the cells
    NSDictionary *blogPost = [self.blogPosts objectAtIndex:indexPath.row];


    //setting the text of the cell and retrieving the titles from the NSDictionary
    cell.textLabel.text = [blogPost valueForKey:@"Title"];
    //setting the detailed text of the cell and reteiveing the authors of the NSDictionary
    cell.detailTextLabel.text = [blogPost valueForKey:@"Author"];

    //returning the cell object
    return cell;
}

1 Answer

Vineet Tiwari
Vineet Tiwari
6,609 Points

You seem to be making the same mistake as I did.

cell.textLabel.text = [blogPost valueForKey:@"Title"]; cell.detailTextLabel.text = [blogPost valueForKey:@"Author"];

Change the uppercase in "Title" and "Author" to "title" and "author" and that should hopefully solve your problem.