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

im a little stuck here?

something wrong with the init method I'm not sure what?

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

class Business { 

let name: String
let location: Location

init() { 
self.name = "Connor"
self.location = 0.0, 0.1
 }
}

let someBusiness = Business()

1 Answer

Kagisho Moroka
Kagisho Moroka
8,716 Points

Hi,

Because location is an instance of the Location struct, you need to add the parameters in your initializer for the location, see below:

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

class Business {

let name: String
let location: Location

init() {
    self.name = "Connor"
    self.location = Location(latitude: 0.0, longitude: 0.1)
}

}

let someBusiness = Business()

Hope this helps.

Happy coding