call a public method on an instance of a class in swift

In Swift, you can call a public instance method on an instance of a class using dot notation.

Assuming you have a class named MyClass and a public instance method named myMethod, here's an example code snippet:

main.swift
let myObject = MyClass()
myObject.myMethod()
45 chars
3 lines

In this example, we create an instance of MyClass using the MyClass() initializer and assign it to myObject. Then, we call the myMethod public instance method on myObject using dot notation.

This way, the myMethod will be executed on the instance of the class MyClass.

gistlibby LogSnag