How to take reference of viewcontroller in NSObject class in swift?

554 Views Asked by At

My requirement is I declared a function in NSObject class I want to use that function in one firstviewcontroller suppose if I want to use that function in secondviewcontroller again firstviewcontroller will call how I can divide those two viewcontrollers in NSObject class can any one tell me?

1

There are 1 best solutions below

0
On BEST ANSWER

You can implement same function in both viewcontrollers with the implementation of protocol. And you can get reference of one viewcontroller in other view controller by using class level method which will return instance of that view controller.