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

kelley riley
kelley riley
3,159 Points

Getting a weird compiler error in challenge text editor only - not in XCode. Code seems good, can anyone help?

Not sure what I'm doing wrong or missing here.

objects.swift
struct Location {
  let latitude: Double
  let longitude: Double
}

class Business {
  name: String
  location: Location

    init(x: Int, y: Int) {
    }

}
let someBusiness = Business(name: "Distillery", location: Location(latitude: 4.4, longitude: 43.1))

1 Answer

Jeff McDivitt
Jeff McDivitt
23,970 Points

You are close but here is how it should look

struct Location {
    let latitude: Double
    let longitude: Double
}

class Business {

    var name: String
    var location: Location

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

    let someBusiness = Business(name: "Dennys", location: Location(latitude: 32.0, longitude: 22.0))

}