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 Displaying API Data with Collection Views in Objective-C Show Me the Data - API’s, OAuth, and NSURLSession NSURLSession

Jared Chu
Jared Chu
4,090 Points

My code should work.

/* Add task 1 code here */ NSURL *url = [NSURL URLWithString:@"http://teamtreehouse.com"];

NSURLRequest *request = [[NSURLRequest alloc] initWithURL:url]; NSURLSession *session = [NSURLSession sharedSession];

/* Add task 2 code below */ NSURLSessionDownloadTask *task; task = [session downloadTaskWithRequest:request completionHandler:^(NSURL * _Nullable location, NSURLResponse * _Nullable response, NSError * _Nullable error){ NSLog(@"Response: %@",response); }];

CodeChallenge.m
/* Add task 1 code here */
NSURL *url = [NSURL URLWithString:@"http://teamtreehouse.com"];

NSURLRequest *request = [[NSURLRequest alloc] initWithURL:url];
NSURLSession *session = [NSURLSession sharedSession];

/* Add task 2 code below */
NSURLSessionDownloadTask *task;
    task = [session downloadTaskWithRequest:request completionHandler:^(NSURL * _Nullable location, NSURLResponse * _Nullable response, NSError * _Nullable error){
        NSLog(@"Response: %@",response);
    }];

1 Answer

Hey Jared,

Your code is correct; it's just that the Challenge is buggy. For now, to pass the challenge, just get rid of each of the _Nullable indicators for the completionHandler's parameters of NSURLSessionDownloadTask. That should let you pass.

CC: Gabe Nadel Pasan Premaratne