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 (Retired) Pulling Data From the Web Creating a URL

Frank Shi
Frank Shi
1,859 Points

Why always "You need to convert the courseID variable to a string and use it when creating courseURL.... "

I was using

let courseID = 25
let treehouseBaseURL = NSURL(string: "https://api.teamtreehouse.com/");
let courseURL  = NSURL(string:"course/COURSE_\(courseID)" , relativeToURL: treehouseBaseURL );

which should be correct.

2 Answers

Chris Shaw
Chris Shaw
26,676 Points

Hi Frank,

The constant courseID isn't being converted to a String per say, what we're doing is using interpolation as explained in Swift Basics: Strings.

The actual value for courseID doesn't change but instead get's concatenated onto the courseURL url string.

Hope that helps.

Frank Shi
Frank Shi
1,859 Points

Thanks Chris, I believe this is a bug in the challenge system, when i use: let courseURL = NSURL(string:"course/COURSE_\(courseID)" , relativeToURL: treehouseBaseURL ); it will fail and when i changed to let courseURL = NSURL(string:"course/\(courseID)" , relativeToURL: treehouseBaseURL ); it works.