Learn Courses My Dashboard

What is an Instance in a shorter way?

Hey guys, I have one other question, I am just a beginner taking the 3.5 hour masterclass, But have one question. What is an instance. I saw one of the post and still didn’t get it, so someone like can put it in a shorter way so I can understand it.
Is it like class, struct, view something like that?

Thanks guys,

In what context? Like can you drop a quote or something where the word instance didn’t make sense?

Someone else posted the same question as me and got replied. I checked that conversation reply which took me to a website. And at the website there still wasn’t anything to help me. So like what is an instance?
Like the actual thing not instance method. I didn’t’ t
really understand what Chris was saying in the video. So can you put it in a shorter way?

Thanks :slight_smile:

Which video was it? Like can you type out the sentence with the word instance that didn’t make sense?

Just so I see which part you’re struggling to understand exactly

You have a type, which is essentially a template for something. A Person or a UIViewController or a Building or whatever.

An instance is one of those things.

Looking at some code:

//this is a TYPE
struct Person {
    let firstname: String
    let lastname: String
    let address: CLLocation
}

//now we create an INSTANCE of that type
let girl = Person(firstname: "Charlotte",
                  lastname: "Grote",
                  address: CLLocation(latitude: 53.3814,
                                      longitude: 1.4884))

An instance method is a function that applies to an instance of a type.

//this is an INSTANCE METHOD
extension Person {
    func name() -> String {
        "\(firstname) \(lastname)"
    }
}

print(girl.name())
//Charlotte Grote

Thank you very much, This helped me a lot

Swift 3.5 hour masterclass

A blueprint for a house are the plans for a house

A blueprint would be a class or struct, the actual house that’s built, that’s an instance of the blueprint

1 Like

That’s a good analogy Mikaela.

1 Like

Thank you guys very much, You guys helped me alot