Declare a class with properties


I want to declare a new class with its own properties, create a new instance and also be able to access its properties.


// Declare our new class

class myClass {

	var myProperty : String
    init(prop: String) {
        // Called when a new object is created
        myProperty = prop

// Create a new object of myClass
let c = myClass(prop:"my property")



Find answers here

Hi there! Ask Us a Question We are ready to help