1

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*

EDIT :

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?

Kevin ABRIOUX
  • 16,507
  • 12
  • 93
  • 99

2 Answers2

1

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.

Kevin ABRIOUX
  • 16,507
  • 12
  • 93
  • 99
0

Take note that currentSWRevealViewController is a method, not a property, and if you want to execute it you should use the following notation, basically adding a pair of round brackets. Otherwise this will return the type of the function that's actually a (function).

let SWVC = DBASplashViewController.currentSWRevealViewController()

Assuming that you have a correct Bridging Header and the staticRVC variable works as expected, this will work.

  • with let SWVC = DBASplashViewController.currentSWRevealViewController() I have the same error – Kevin ABRIOUX Jun 16 '16 at 13:05
  • @Imbru what your Bridging Header file looks like? I just tried to replicate your issue and I was able to make it work perfectly, check the .zip project here http://jmp.sh/wXYRfn5 – Lorenzo Zanotto Jun 16 '16 at 13:09
  • i have this line in my bridging header : #import "DBASplashViewController.h". DBASplashViewController is recognized. I check your sample project – Kevin ABRIOUX Jun 16 '16 at 13:42
  • I don't see any difference between both code and I still don't understand why I can't access to my static method – Kevin ABRIOUX Jun 16 '16 at 13:48