In my custom view I’ve created one button. To add action for that button which is feasible solution Creating Delegate method or Declaring UIButton
as global variable and addTaget
. Suggest me please.
I'd highly recommend not using global vars as much as possible. Global data (constants) are good, but global variables are high maintenance since anyone can modify it.
There are 2 cases why you may want a global variable: