How to use Objective-C code with #define macros in Swift
What I did is to create a class method that returns the #define.
Example:
.h file:
#define AD_SIZE CGSizeMake(320, 50)+ (CGSize)adSize;
.m file:
+ (CGSize)adSize { return AD_SIZE; }
And in Swift:
Since this is a class method you can now use it almost as you would the #define.If you change your #define macro - it will be reflected in the new method you createdIn Swift:
let size = YourClass.adSize()
I resolved this by replacing
#define AD_SIZE CGSizeMake(320, 50)
in the library's Constants.h
with
extern CGSize const AD_SIZE;
and adding
CGSize const AD_SIZE = { .width = 320.0f, .height = 50.0f };
in the library's Constants.m
file.
write your constants after Class declaration. like this...
class ForgotPasswrdViewController: UIViewController {let IS_IPHONE5 = fabs(UIScreen.mainScreen().bounds.size.height-568) < 1;let Tag_iamTxtf = 101