How do I implement a custom delegate to a class in iOS?
How do I implement a custom delegate to a class in iOS?
There’s basically three steps:
Define a delegate protocol:
protocol MyDelegate : AnyObject { func someMethod() }
.
Define a delegate property in your class:
class MyClass { weak var delegate: MyDelegate? = nil }
.
Call that delegate:
self.delegate?.someMethod()
.
Share and Enjoy
—
Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware
let myEmail = "eskimo" + "1" + "@apple.com"