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 trialAndrea Cabral
Courses Plus Student 10,819 Pointsno 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
23,274 PointsThe 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
Courses Plus Student 10,819 PointsYea 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
Courses Plus Student 10,819 Pointsa screenshot of the consol and the simulator :
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
23,274 PointsHm, I would check 3 things:
- Make sure you have the correct frameworks in your Xcode project.
- Check the syntax in the BR2BlogPost class.
- Try resetting your simulator. Run the app and go to iOS Simulator > Reset Content and Settings...
Good luck!
BC