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
miles fishman
Courses Plus Student 3,610 PointsCant get the custom class to get the blogs showing on the simulator ? am I implementing incorrectly ?Objective C
Here is the tableview controller implementation
- (void)viewDidLoad
{
[super viewDidLoad];
NSURL *treehouse=[NSURL URLWithString:@"http://blog.teamtreehouse.com/api/get_recent_summary/"];
NSData *jsondata=[NSData dataWithContentsOfURL:treehouse];
NSError *error=nil;
NSDictionary *json=[NSJSONSerialization JSONObjectWithData:jsondata options:0 error:&error];
NSLog(@"%@",json);
self.blogPostsA=[NSMutableArray array];
NSArray *postArray=[json objectForKey:@"posts"];
for (NSDictionary *postsClean in postArray) {
blogpost *cleaner=[blogpost initWithBlogPost:[postsClean objectForKey:@"title"]];
cleaner.author=[postsClean objectForKey:@"author"];
}
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{ static NSString *CellIdentifier=@"cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
blogpost *blogPost=[self.blogPostsA objectAtIndex:indexPath.row];
cell.textLabel.text= blogPost.title;
cell.detailTextLabel.text= blogPost.author;
// Configure the cell...
return cell;
}
1 Answer
miles fishman
Courses Plus Student 3,610 PointsFigured it out, I forgot to add
[self.blogPostsA addObject:cleaner];
at the end of the 'for' loop
miles fishman
Courses Plus Student 3,610 Pointsmiles fishman
Courses Plus Student 3,610 Points"blogpost" is my custom class