I have following code in my Appdelegate
class and want to access that in Objective C file for that I have already created Bridging file which works well for all methods.
public var loggedInUserModelObject = LoggedInUserModel(userDict:[String:Any]())
But when I try to access loggedInUserModelObject
variable in objective C class it shows me This error.
I used @objC
before the class and before the variable too but no success.
how can I access pubic variable in objective c file
Are you using swift4?Rules of accessing variables have changed in swift 4.Instead of using @objc prefix in swift class use @objcMembers. This will expose all variables to objective c class. Example is given below.
@objcMembers class AppDelegate: UIResponder, UIApplicationDelegate, UISplitViewControllerDelegate
If you want to expose single variable to swift class, use @objc before variable like the code shown below.
@objc public var loggedInUserModelObject : NSString?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With