Imbru Imbru - 1 year ago 111
Swift Question

Access static objective C method in Swift

In my Obj-C files, I have this static member and getter :

//******* DBASplashViewController.m ********
static SWRevealViewController *staticRVC;
+ (SWRevealViewController*)currentSWRevealViewController
return staticRVC;

//******* DBASplashViewController.h ********
+ (SWRevealViewController*)currentSWRevealViewController;

In my swift code, I have an error on this line :

let SWVC = DBASplashViewController.currentSWRevealViewController

Error :
*DBASplashViewController has no member currentSWRevealViewController*


This is my bridging file :

#import "DBASplashViewController.h"

As you can see, DBASplashViewController is perfectly interpreted by XCode, but not the static method :

enter image description here

What have I done wrong?

Answer Source

After a long investigation, it appears i have a missing import in my bridging header.

DBASplashViewController.currentSWRevealViewController() must return a object of type SWRevealViewController.

It appears i have forgotten to have the line in my bridging header :

#import "SWRevealViewController.h"

Since the return type is define on Swift part, i can access to my static variable.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download