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

Martel Storm
Martel Storm
4,157 Points

Object-Oriented Swift 3, Classes with Custom Types, Challenge Quiz

I feel like i'm close to the right answer... please dear baby Jesus let me be close to the right answer!

I think i'm improperly using the initializer and to be honest I don't have the strongest understanding of how an initializer works.

Per usual if you have any noob tips to save time and to increase motivation I would greatly appreciate it! I'm super eager to hear what you smart people out there have to say!

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 = "Twitch"
        self.location = Location(latitude: 2, longitude: 4)
    }
}
let someBusiness = Business(name: "Amazon", location: Location(latitude: 2, longitude: 4)

1 Answer

David Papandrew
David Papandrew
8,386 Points

Martel,

You are so freaking close on this one!

So here's what's missing: A SINGLE CLOSE PARENTHESIS. That's it.

Here's the line you need to fix:

let someBusiness = Business(name: "Amazon", location: Location(latitude: 2, longitude: 4))

It's the final closing paren at the end of the line.

So one quick tip I can give you is this: use the Xcode Playgrounds. If you type up your Treehouse challenge answer in a Playground FIRST, you can usually find any mistakes before submitting your answers (at least you can find the mistakes much more easily in the Playground than in the Treehouse exercise tool).

Lastly, things like closing parens or brackets or curly braces are common sources for errors. So always double check to make sure that if you opened a paren, you are also closing them too.

Good luck.