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

Code challenge won't accept my answer - Adding the Edits Friends Screen 2/3 iOS

Stuck stuck stuck. Entered my answer and it looked correct but I keep getting an error that the syntax is wrong. I looked on the forums and comparing answers and mine should be correct. It is late at night so maybe I'm missing something blatantly obvious but I don't think so. I have to go sailing tomorrow morning so maybe it's a good idea that I get some sleep, thank you treehouse god haha

Question: Now send the 'findObjectsInBackgroundWithBlock' message to the 'query' variable. Use the code that is commented out as the basics for the block you pass in.

My Answer:

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

@implementation AppsViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    [PFQuery queryWithClassName:@"Apps"];
    [query findObjectsInBackgroundWithBlock:^(NSArray *objects, NSError *error) {
        if (error) {
            NSLog(@"Error: %@ %@", error, [error userInfo]);
        }
        else {

        }
    }];
}

@end

P.S. Amit Bijlani Ben Jakuben thanks for the amazing iOS courses. At first I was extremely confused but you guys explain it so well and once I start working on my own apps I'm going to have such a better foundation thanks to you guys! :)

4 Answers

the answer is

[PFQuery queryWithClassName:@"Apps"]; [query findObjectsInBackgroundWithBlock:^(NSArray *objects, NSError *error) { if(error) { NSLog(@"Error %@ %@ ",error,[error userInfo]); } else{
self.Apps=objects; } }];

Still doesn't work.

Amit Bijlani
Amit Bijlani
Treehouse Guest Teacher

You are almost right but the first question asks you to create a variable named query. None of the answers here have created a local variable named query and then assign it [PFQuery queryWithClassName:@"Apps"];

I am having the same problem with the challenge not accepting my code. Here is what I have tried to enter.

    [query findObjectsInBackgroundWithBlock:^(NSArray *objects, NSError *error) {
    if (error) {
        NSLog(@"Error: %@ %@", error, [error userInfo]);
    }
    else {

    }
}];

}

@end

you are missing that line [PFQuery queryWithClassName:@"Apps"]; and a curly bracket at the end try to run to Xcode and then copy it and paste it to treehouse compiler

I didn't include the [PFQuery queryWithClassName:@"Apps"] code here since I knew that part of the challenge wasn't my issue. My error ended up being caused from bad syntax on my part. One of my curly brackets was in the wrong spot.

Thanks to everybody for getting back to me! Time to finish up this app :)

Admit I got some questions how can I reached please