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 Interacting with Data From the Web Constructing a URL

Florian Groussin
Florian Groussin
4,563 Points

I don't get it :(

Hello,

I don't know why it doesnt worked, i think i don't fully understand the question

I tried lots of possibilities but obviously not the right one...

Please help me on that

Happy NEW YEAR! Florian

urls.swift
import Foundation

var treehouseCourseID = 25

let treehouseBaseURL = NSURL(string: "https://api.teamtreehouse.com/")

let courseURL = NSURL(string: "COURSE_\(treehouseCourseID)/", relativeToURL: treehouseBaseURL)

3 Answers

Steven Deutsch
Steven Deutsch
21,046 Points

Hey Florian Groussin,

You have the set up correct, you're just not creating the proper URL in the end.

Your final URL must follow this format. https://api.teamtreehouse.com/course/COURSE_ID.

import Foundation

let treehouseCourseID = 25

// Add your code below

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

Good Luck

Florian Groussin
Florian Groussin
4,563 Points

Dankeschรถn es hat geklappt :)

So if I Understand String interpolation is: (name)?

Thanks you again!

guten Abend

Steven Deutsch
Steven Deutsch
21,046 Points

You were doing string interpolation correctly.

/* https://api.teamtreehouse.com/course/\(treehouseCourseID) is the full link we need

You currently have treehouseBaseURL set to this part:
https://api.teamtreehouse.com/

So, your courseURL needs to add this part:
course/\(treehouseCourseID)

Relative to your treehouseBaseURL

This makes the full link
https://api.teamtreehouse.com/course/\(treehouseCourseID)

*/

Viel Glรผck

Florian Groussin
Florian Groussin
4,563 Points

Danke alles ist wieder klar !

Bis balt Steven