Swift Delegate


protocol TestDelegate : class {
    func method1()
    func method2()

To use waak, we need to inherit class

id in UIView

In Objective-C, we use @property (nonatomic, weak)id delegate in your class.
But, in swift there is a bit difference.

internal weak var delegate : TestDelegate?


Next, you need to implement delegation protocol

class TargetClass : NSObject, TestDelegate {

   func method1() {
   func method2() {


Learn Swift from Objective-C : Protocols and Delegation