Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR SWIFT

Swift Access Control

class Student {

  // private property
  private var name = "Tim Cook"

  // private method    
  private func display() {
    print("Hello from Student class")
  }
}

// create object of Student class
var student1 = Student()
    
// access name property
print("Name:", student1.name)

// access display() method 
student1.display()
 
PREVIOUS NEXT
Tagged: #Swift #Access #Control
ADD COMMENT
Topic
Name
5+2 =