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
Wayne Knoesen
9,435 PointsHaving troubles with Retrieving Data from parse.com
Hi,
I have no idea what I am doing wrong: 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!"
This is what i believe the answer to be:
// Insert code here!
[query getObjectInBackgroundWithId:@"1" block:^(PFObject *object, NSError *error) {
if (error) {
//do something
}
else {
NSLog(@"Move retrieved!");
}
}];
Am I missing something?
3 Answers
John W
21,558 Points(Edited for markdown)
The question may not require you to check for error. Try removing the if/else statements and simply call NSLog instead.
It's a good habit to check for error if one is provided though. Good for you!
Wayne Knoesen
9,435 PointsTried that already I am sorry to say. How do I get that nice Code block to show? I used the Markdown Cheetsheet and wrapped the code in the ```.
Wanted to show that I tried that already :-)
John W
21,558 PointsMake sure you leave a blank line before the opening and closing for the code markdown
Ben Jakuben
Treehouse TeacherYour code worked for me with removing the if/else part (just keeping the NSLog statement). Were you able to get past this? We had some issues with our iOS code challenges a while back and perhaps that was also contributing.
Wayne Knoesen
9,435 PointsHi Ben, I got it to work :)
I think I caught the code challenge tool on a bad day. Thanks again for all the awesome lessons!
Andrew Brotherton
7,515 PointsI've tried this and it simply isn't working. I'm only calling NSLog, entered the block and this simply won't work?
- (void)viewDidLoad {
[super viewDidLoad];
[query getObjectInBackgroundWithId:@"1" block:^(PFObject *object, NSError *error) {
NSLog(@"Move retrieved!");
}
}];
Ben Jakuben
Treehouse TeacherA simple mistake that is easier to detect in Xcode...you just have an extra curly brace after your NSLog call. :-/