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 2.0 Classes Classes with Custom Types

I'm stuck, where have I gone wrong?

I have tried and failed but cannot seem to find an answer. I would love help :). Thnks

classes.swift
struct Location {
    let latitude: Double
    let longitude: Double

    class Business {
let name: String
let location: Location
    }

init (latitude: Double, longitude: Double){
name: "\(Peace)"
location: 1.0, 1.0
    } 
}

let someBusiness = Business.init

1 Answer

Here's the code that'll work. I'd recommend watching the videos again to get a better grip on the concept though. Hope this helps.

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

class Business {
    let name: String
    let location: Location


    init (name businessName: String, latitude: Double, longitude: Double) {
        self.name = businessName
        self.location = Location(latitude: latitude, longitude: longitude)
    } 
}

let someBusiness = Business(name: "Any Business Name", latitude: 12.345, longitude: 67.890)

Yeah the concepts are pretty tricky, but thanks!