Swift Delegate

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?

Implementation

Next, you need to implement delegation protocol

class TargetClass : NSObject, TestDelegate {

   func method1() {
   }
   
   func method2() {
   }
}

Ref

Learn Swift from Objective-C : Protocols and Delegation