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

Cant 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;
}

"blogpost" is my custom class

1 Answer

Figured it out, I forgot to add

[self.blogPostsA addObject:cleaner];

at the end of the 'for' loop