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 trialkaitlanlang
3,042 Pointscreating a URL first challenge in swift weather API
It is not completely clear to the learner exactly what is being asked ( this pattern is driving me crazy, once i know whats being asked its easy) I can only deduce the below code answers the question, this being a 'base' url i would have thought it fine
import Foundation
let courseID = 25
let treehouseBaseURL = NSURL (string: "https://api.teamtreehouse.com/")
then i tried the following in case this was what was wanted
import Foundation
let courseID = 25
let treehouseBaseURL = NSURL (string: "https://api.teamtreehouse.com/\(courseID)/")
However you put it through the parser and it says something wrong.. I am most likely answering something different. ( works in Xcode).
Please tee house staff some clarity for the learner in your questions.
note: I have read changes in Xcode in teachers notes, does not seem to change anything with this particular code as i have presented it, but will when i use nsdata
some help from all would be great but some input from a trehouse staff please
2 Answers
Stone Preston
42,016 PointsI tried your first code and it worked fine for me
import Foundation
let courseID = 25
let treehouseBaseURL = NSURL (string: "https://api.teamtreehouse.com/")
although generally you dont put space after the initializer:
let treehouseBaseURL = NSURL(string: "https://api.teamtreehouse.com/")
but it accepted it either way.
could have been a problem with the CC engine. And I agree, this challenge is pretty ambiguous and lacks the direction that most of the other challenges have.
kaitlanlang
3,042 PointsHi Stone, somehow i got it right. Thanks for post. i submitted my answer with iOS app the same as you have and it failed, i then tried it in browser on mac same as you have and it failed, i amend space and it failed, then I submitted it with more code that seemed extra to question and it worked. My logic would have thought what you did was enough but it would not work without next line of code. Haven't done next question but maybe question and answers are out of sync e.g. the answer that worked for me is next question.( was just speculating)
kaitlanlang
3,042 PointsHi stone, onto next question and it looks like what i said in last post is the case, the question is asking me for the answer that worked in last one.
Stone Preston
42,016 Pointsim not sure I understand what is going on. can you post the task you are currently on and the code you currently have entered
kaitlanlang
3,042 Pointsdisregard last post, it appeared that way at start
kaitlanlang
3,042 PointsTo clarify my questions and answers are not out of sync it just appeared that way when i got to next question. With regards to this question it only accepted it when i put in second line of code ( commented out as line2) as posted where i said this worked
Stone Preston
42,016 Pointsok so you passed the challenge then correct?
kaitlanlang
3,042 Pointsyes i have completed code challenge both questions, i am still thrown by first question needing more code than what worked for you. i shall take it as what worked for you as programatically correct for question and what worked for me as a processing engine glitch and superfluous. Thanks for your help. i did drag post on I'm sorry but it will be useful if others to read if they have similar issue. Thanks :)
kaitlanlang
3,042 Pointskaitlanlang
3,042 PointsThrough monkey see monkey do trial and error rote learned i arrived at correct answer, there is nothing in question about constant courseURL, i guessed that one. question asked for baseURL that was achieved in line1