Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR SWIFT

Swift Access Struct Properties Swift

// define a structure 
struct Person {

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

// create instance of Person
var person1 = Person()

// access properties and assign new values
person1.age = 21
person1.name = "Rick"

print("Name: (person1.name) and Age: ( person1.age) ")
 
PREVIOUS NEXT
Tagged: #Swift #Access #Struct #Properties #Swift
ADD COMMENT
Topic
Name
6+5 =