I am very new to Swift. I have one hybrid project in which some classes are in Objective-C and some are Swift. I have one Constant.h file which is based with Objective-C file. In this header file have mention some constant like bellow
#define mainViewBgColor [UIColor colorWithRed:248.0/255.0 green:247.0/255.0 blue:247.0/255.0 alpha:1.0]
But problem is that i can't access this constant in Swift class. See bellow Swift code
override func viewDidLoad() {
super.viewDidLoad()
self.view.backgroundColor = mainViewBgColor //Want to access liek this but this line gives me an error.
self.loadNavigation();
}
Please suggest the right way to access constants like this specifically the constant write in Objective-C.
Note : Please consider that i have Bridging-Header.h file and i have already import the constant file into that bridge file. Even i can successfully access simple string constant.
Edited Alternate Solution : I have found the alternate solution for using constants in swift is to create new swift constant file let say SwiftConstant.swift and define the constant like bellow in this file.
let mainViewBgColor = UIColor(red: 248.0/255.0, green: 247.0/255.0, blue: 247.0/255.0, alpha: 1.0)
now without importing SwiftConstant.swift file anywhere i can use the constant. i don't know this is right way or not hoping and wait for good answer.