简体   繁体   中英

How to access variables from swift class to objective c class

I have a requirement where i had to integrate a swift class in my objective c coding. I am pretty new to this concept, but I was able to integrate swift file into objective c code with some online guiding.After integration, i need to set some values to swift class variables from objective C class which am not able to do so. I am not able access the variables that are declared in swift class.While integrating swift class, i didn't implement any init() or initwithframe in swift class. Can someone please guide me on how to access swift class variables from objective c class.

Right click on project and choose New File then please check the screen shots 在此处输入图片说明

Then Would you like to configure an Objective-C bridging header? this will come then press on Create Bridging Header, now in bridging-Header.h you can import as #import "Viewcontroller.h"

In your Swift class use

 class filenew 
 {
     init()
   {

   }
 }

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