简体   繁体   中英

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

我的要求是我在NSObject类中声明了一个函数,我想在一个firstviewcontroller中使用该函数,假设如果我想再次在secondviewcontroller中使用该函数,firstviewcontroller会调用我如何在NSObject类中划分这两个viewcontrollers的人,可以告诉我吗?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM