Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

iOS Build a Blog Reader iPhone App Data Modeling Using a Custom Class

Andrea Cabral
PLUS
Andrea Cabral
Courses Plus Student 10,819 Points

no title nor author name appearing in the simulated tableview app. When is tableview:cellForRowAtIndexPath called ?

I put a NSLog in it, just to see if the function was called but it isn't...

however, i do have that every time I run the app (had it since the beginning, so might not be related to that problem though...)

2014-08-31 19:04:14.256 BlogReader2[39327:60b] Cannot find executable for CFBundle 0x8c5b5a0 </Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator7.1.sdk/System/Library/AccessibilityBundles/CertUIFramework.axbundle> (not loaded)

4 Answers

Robert Conti
Robert Conti
23,274 Points

The tableView:cellForRowAtIndexPath method is essentially presenting a cell to the table view controller (hence why we return 'cell' in the method). So when you define what your cell looks like and contains, this method then returns 'cell' so that it shows up in your table view. So when you run the app, if you are seeing cells, then your tableView:cellForRowAtIndexPath is being called. If there are no cells, then this is most likely where the issue is. Here is the example method:

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

    BlogPost *blogPost = [self.blogPosts objectAtIndex:indexPath.row];

    if ( [blogPost.thumbnail isKindOfClass:[NSString class]]) {
        NSData *imageData = [NSData dataWithContentsOfURL:blogPost.thumbnailURL];
        UIImage *image = [UIImage imageWithData:imageData];

        cell.imageView.image = image;
    } else {
        cell.imageView.image = [UIImage imageNamed:@"treehouse.png"];
    }
    cell.textLabel.text = blogPost.title;
    cell.detailTextLabel.text = [NSString stringWithFormat:@"%@ - %@",blogPost.author,[blogPost formattedDate]];
    return cell;
}
Andrea Cabral
PLUS
Andrea Cabral
Courses Plus Student 10,819 Points

Yea alright, got that, but what happens to the NSLog I inserted in that function that does not appear in the console ?

My code below:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *CellIdentifier = @"Cell";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
    BR2BlogPost *blogPost = [self.blogPosts objectAtIndex:indexPath.row];

    NSLog(@"ok");

    cell.textLabel.text = blogPost.title;
    cell.detailTextLabel.text = blogPost.author;

    return cell;
}```
Andrea Cabral
PLUS
Andrea Cabral
Courses Plus Student 10,819 Points

a screenshot of the consol and the simulator :

screenshot

looks like I couldn't embed the picture...but here is what the consol looks like when I run the blog reader app :

2014-09-01 13:42:25.111 BlogReader2[40975:60b] Cannot find executable for CFBundle 0x8ea5420 </Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator7.1.sdk/System/Library/AccessibilityBundles/CertUIFramework.axbundle> (not loaded)

Robert Conti
Robert Conti
23,274 Points

Hm, I would check 3 things:

  1. Make sure you have the correct frameworks in your Xcode project.
  2. Check the syntax in the BR2BlogPost class.
  3. Try resetting your simulator. Run the app and go to iOS Simulator > Reset Content and Settings...

Good luck!

BC