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

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