I am unable to see the method/variable to set myVar
to true
from Objective C even tough I've added the @objc
and public
modifiers and there is no Bool
in the setMyVarTrue()
method's signature.
This is probably caused by the difference between Swift's Bool
and Objective C's BOOL
.
Other class methods/variables are visible, just this particular one isn’t.
How is is possible to set Swift's Bool
from Objective C?
Swift code:
public class MyViewController : UIViewController {
public var myVar:Bool = false
@objc public func setMyVarTrue() {
self.myVar = true
}
}
Objective C code:
MyViewController* myViewController = [MyViewController new];
myViewController.myVar = true // Variable not found
myViewController.setMyVarTrue() // Method not found
[self presentViewController:myViewController animated:NO completion:nil];