Understanding of the protocol in Swift

There are two views
Make a Protocol
  • Implement a protocol. and define a function in there. but you don’t need to implement code in the function. Just define name and variables only.
make an instance of protocol and call the function of the protocol
  • In there ViewController of child_view, make a new instance as the Protocol (the name is not ‘Protocol’ it is your own)
  • call the function on your wish, any place.
set the Class as a delegate you want to receive a notifying
extend the receiver class as the Protocol. and implement actions when you get notifying

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Fredric Cliver

Fredric Cliver

Majored in Physics, self-taught and worked in the IT industry as a Dev/Design/Planning for 11 years. And I had run my Startup for 3 years. I fancy a ☔️ 🇬🇧