To call a method on an instance of a class in Swift, you first need to create an instance of the class. You can do this using the init()
method of the class.
Assuming you have created an instance of the class, you can then call methods on it by using the following syntax:
main.swift22 chars2 lines
Here's an example, assuming you have a class called Person
with a method called sayHello()
:
main.swift136 chars6 lines
This will call the sayHello()
method on the person
instance of the Person
class.
gistlibby LogSnag