Imbru Imbru - 3 months ago 14x
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?


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.