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

Domenico Mazzella Di Bosco
Domenico Mazzella Di Bosco
2,357 Points

I am lost.

I seriously do not know what this is asking me to do

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

class Business {
    let name: String
    let location: Location

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

let someBusiness = Business(name: "1pf", location: Location)

2 Answers

Hi there,

You're preetty much there!!

When you call the new object of Business you want to create a new Location in the constructor. So, after where you've typed Location add a set of brackets and pass in a latitude: 1.23 and a longitude: 53.1 and your code is fine!

My numbers are just examples of type Double.

I hope that helps,

Steve.

:+1: :smile:

Domenico Mazzella Di Bosco
Domenico Mazzella Di Bosco
2,357 Points

finished it with this

html <p>This is code!</p>
struct Location {
    let latitude: Double
    let longitude: Double
}

class Business {
    let name: String
    let location: Location

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

let someBusiness = Business(name: "domenic", location: Location(latitude:12.2,longitude: 12.4))

Looks good! :+1: