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

Andrew Brotherton
Andrew Brotherton
7,515 Points

Code Challenge: Retrieving and showing data from Parse.com- answer not working.

Code Challenge Task 2 of 2 I've tried this and it looks right. The block has a PFObject, and NSError and has NSLog in the block and it doesn't work? This is the question Now add a block parameter. It should have a PFObject as its first parameter and an NSError as its second parameter. Inside the block, use NSLog to log the message "Move retrieved!"

` #import "GameViewController.h"

import <Parse/Parse.h>

@implementation GameViewController

  • (void)viewDidLoad { [super viewDidLoad];

    PFQuery *query = [PFQuery queryWithClassName:@"Move"];

    [query getObjectInBackgroundWithId:@"1" block:^(PFObject *object, NSError *error) { NSLog(@"Move retrieved");

    } }];

@end

Stone Preston
Stone Preston
42,016 Points

can you post a link to the challenge?

4 Answers

Andrew Brotherton
Andrew Brotherton
7,515 Points

I just realized i had gotten the last two brackets mixed up, I had } }]; instead of }]; }

did the same!

Stone Preston
Stone Preston
42,016 Points

you have an extra curly brace at the end of your block and are also missing the ! on the end of your NSLog message

[query getObjectInBackgroundWithId:@"1" block:^(PFObject *object, NSError *error) { 
        NSLog(@"Move retrieved!");
    }];
Andrew Brotherton
Andrew Brotherton
7,515 Points

I just tried that and it doesn't work?

[query getObjectInBackgroundWithId:@"1" block:^(PFObject *object, NSError *error) { NSLog(@"Move retrieved!"); }];

Stone Preston
Stone Preston
42,016 Points

not sure why it didnt work. I just passed jsut fine using it:

#import "GameViewController.h"
#import <Parse/Parse.h>

@implementation GameViewController

- (void)viewDidLoad {
    [super viewDidLoad];

    PFQuery *query = [PFQuery queryWithClassName:@"Move"];

    // Insert code here!
    [query getObjectInBackgroundWithId:@"1" block:^(PFObject *object, NSError *error) { 
        NSLog(@"Move retrieved!");
    }];
}

@end