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!

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 Object-Oriented Swift Classes in Swift Classes with Custom Types

Anybody know what I've done wrong?

This is the question, and I seem to be stuck. It will be great if anybody could help. Thanks!

In the editor you've been provided with a struct named Location that models a coordinate point using longitude and latitude values.

For this task we want to create a class named Business. The class contains two constant stored properties: name of type String and location of type Location.

In the initializer method pass in a name and an instance of Location to set up the instance of Business. Using this initializer, create an instance and assign it to a constant named someBusiness.

struct Location {
  let latitude: Double
  let longitude: Double
class Business {
    let name: String
  let location: String

  init(name: String, location: Location) {
    self.name = name
    self.location = location

 let someBusiness = Business(name: "Google", location: Location(latitude: 55.0, longitude: 76.0))

1 Answer

Magnus Hållberg
Magnus Hållberg
17,232 Points

The only thing wrong is your location constant, its supposed to be of type Location. Yours is of type String. That's it.

Thank you so much!! :)