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 trialBritt Green
2,611 PointsIs anyone else completely lost when it comes to closures?
Am I the only one who is absolutely lost with regards to closures? I kiiiiind of get what they are, and how they are used. But this video has me completely lost and frustrated. Even watching the lectures on closures a second time hasn't really helped. Any other resources I could watch that help explain this concept?
Roland Shen
7,628 PointsI'm having the exact same problem. I don't really understand anything from these recent lessons because closures just dont make sense to me.
11 Answers
Antonija Pek
5,819 PointsI have the same problem and I will probably quit my Treehouse subscription because of that. I watched Closures a few times and not a single piece of code made any sense to me. Now, everything is so hard and I don't understand anything. I am very disappointed.
Roberta Voulon
5,792 PointsI don't think Treehouse is at fault here, closures are pretty complex and it takes some time for your brain to get it. Find resources that explain the same thing in different ways, re-watch the videos until it sinks in. Some people decide to not deal with networking and JSON at first but for me it's a core skill I really want to have, so that helps me to keep pecking at it. If you're really not that interested in JSON, you might as well skip it for now until you have a project that you really need it for.
Bryan Marks
3,987 PointsI think this is a decent website to get some straightforward information : http://fuckingswiftblocksyntax.com/
Not an all encompassing website though and with most things in coding it's just practice....
Ramiro Martinez
13,858 PointsI'm lost too, I feel just like I'm copying code but not learning..... And I saw the clousures course 2 times....
Brian Patterson
19,588 PointsI think it is always good to have a look around and see what other sites have done. I thought this was a really good video https://www.youtube.com/watch?v=__1B5m-gE9A . I know its basic but it is a starting point and doesn't too much code speak. The problems I find with sites like Treehouse, which I say do a good job, is that they become too technical and one can get lost with the language. This video explains it in very layman terms. Unfortunately the link does not work.
james bunn
2,377 Pointsthat link does not work
Roberta Voulon
5,792 PointsI'm just learning it over and over again, doing the videos several times and using other resources (YouTube!) that explain it slightly differently, or refer to Apple's documentation to help with the syntax. Every day a chunk goes >clunk< in my head and I think eventually it'll all fit :) Hang in there everybody! Don't let go now, the more consistently you work on this the easier it gets!
Luis Miguel
Courses Plus Student 644 Pointsi was too, but doing some digging i find out that the completion it's just the return type of a closure (callback) , so the best way of think about the "completion handler" is thinking about it like if it were the return type of any function.
so, in the networkOperation class we wanted to download the JSON from the URL, that why the completion is of type [String:AnyObject] because our JSON is on that format. and we wanted back on the completion. the same way on the forecastService struct we wanted a instance of CurrentWeather with the values of the json on it (this is called: parsing the JSON) take parsing the JSON like reading the JSON.
Alex Yakir
5,425 PointsI feel the same. I would love it if Pasan could slow down the pace a little bit.
david zere
293 PointsI've spent like 2 days just watching 3 classes and digging through a lot of online examples and documentation. The order of this classes are wrong. You can't understand these classes if you don't watch the Closures section, but also, you can't understand the Closures section if you don't know how the network operation works, but network operation are on the Build a Weather App section. Kept bouncing back and forth. That's way too confusing. Another thing, like in this video, he called the "downloadJSONFromURL" method, and started getting rid of those parenthesis like a ninja, just like all of us are already masters in trailing closures. This is just WAY TOO FAST!
Caleb Kleveter
Treehouse Moderator 37,862 PointsDid you do the course? If you haven't, it might help.
Britt Green
2,611 PointsYep, did the course. I'm actually going thru it a second time, and finding it a little more helpful to redo it.
Amitai Blickstein
6,863 PointsFor all those who downvoted: In the course on the swift app, it is fair to forward closure-specific questions to the closures course. In the closures course, closure-specific questions will/should be answered (and dodging a question there might merit a downvote). DRY, right?
That said, I am sympathetic. I am reading these answers because of my own closures troubles, even having gone through the other course.
Brian Patterson
19,588 PointsI am completely lost as well. Very disappointed as I am not getting any of this.
jeyaganesh rajamanickam
3,269 PointsYes, it is very complex to understand. New version of Xcode and Swift showing some errors too.
Peter Nellius
6,898 PointsPeter Nellius
6,898 PointsI agree that closures are a difficult concept to grasp and would also like some clarification on this topic.