Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR SWIFT

Swift Class and Objects

// define a class
class Bicycle {

// define two properties
var name = ""
var gears = 0
}

// create instance of Person
var bike1 = Bicycle()

// access properties and assign new values
bike1.gears = 11
bike1.name = "Mountain Bike"

print("Name: (bike1.name), Gears: ( bike1.gears) ")
 
PREVIOUS NEXT
Tagged: #Swift #Class #Objects
ADD COMMENT
Topic
Name
4+7 =