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 Build a Weather App with Swift Managing Complexity Callback Methods With Closures

Alex M
Alex M
6,117 Points

Cannot get method syntax

I think I wrote a valid code. It works in Xcode. Can't get what's wrong.

Callbacks.swift
import Foundation

// Add your code below

func fetchTreehouseBlogPosts(completion: (NSData!, NSURLResponse!, NSError!) -> ()) {

}
Alex M
Alex M
6,117 Points

It says: Make sure the method is named fetchTreehouseBlogPosts and has the correct syntax!

and no error in console

2 Answers

Hi Alex,

Have a look at this code - see if that makes sense to you:

typealias BlogPostCompletion = ((NSData!, NSURLResponse!, NSError!) -> Void)

func fetchTreehouseBlogPosts(completion: BlogPostCompletion) {

}

Steve.

Caleb Kleveter
Caleb Kleveter
Treehouse Moderator 37,862 Points

That's weird, it seems that when you read the instructions from the challenge you don't have to create the typealias.

No, it's optional - I just find it easier to do it that way else the line gets long and that confuses me. :-D

Alex M
Alex M
6,117 Points

Thanks