First of all, start by creating a new Swift file and name it something like HLRequestDelegate ; that will define your protocol.

To call your delegate, you may now create a new class instance and call methods defined in previous Swift file.

The last thing to do is to implement our delegate. Open your Swift class and add your protocol at the top of class declaration, and implement the methods, this way:

You can now get your methods called by assigning delegate:

Find complete snippet here.

Partager