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 trialRashii Henry
16,433 PointsNow Create a download Task and NSlog the response?
I'm actually having trouble with task two of Build a Photo Browser Iphone app.
If i'm not mistaken the download task is already created underneath the 'Add task 2 code below' comment.
So in my opinion the download task is already created. However, from my notes (also in the video) the NSURLSessionDownloadTask was created and initialized all in one line.
I'm not confused about the NSLog part of the question, nor do i want the answer. But i want to understand the question completely and possibly get someone's feedback on how i can get to the correct answer.
For reference, this is all the code i have && i'm not sure what else to add or remove because the compiler in the code challenge is not assisting me at all.
NSURLSessionDownloadTask *task = [session downloadTaskWithRequest:request completionHandler:^(NSURL *location, NSURLResponse *response, NSError *error) {
} NSLog(@"Response: %@", response);
2 Answers
Thomas Nilsen
14,957 PointsIt should look something like this :)
task = [session downloadTaskWithRequest:request completionHandler:^(NSURL *location, NSURLResponse *response, NSError *error) {
NSLog(@"Response: %@", response);
}];
Sorry, didn't see the part about not wanting the answer. But your answer is correct if you just move the NSLog statement inside the completionhandler
Wayne Knoesen
9,435 PointsI have this as my code. The task was created for us already, but i do feel my code lives up to the requirements of the task.
Can anyone see what i might have missed?
/* Add task 1 code here */
NSURL *url = [[NSURL alloc] initWithString:@"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 *location, NSURLResponse *response, NSError *error) {
NSLog(@"Responce: %@", response);}];
Wayne Knoesen
9,435 PointsI seem to have misspelt Responce HAHA oops....