I have a var defined in one Swift file, but in another Objective-C file, when I try to set this var, the complier complains it cannot find the var. How do I solve this problem? here is the code: in swift:
var isCreating: Bool!
in objc :
SelectMemberViewController *ctrl = [[SelectMemberViewController alloc]init];
ctrl.isCreating = YES
then the complier is complaining : Property 'isCreating' not found on object of type 'SelectMemberViewController'
Swift recognizes a value as boolean if it sees true or false . You can implicitly declar a boolean variable let a = false or explicitly declare a boolean variable let i:Bool = true .
In Objective-C, any character , numeric or boolean literal prefixed with the '@' character will evaluate to a pointer to an NSNumber object (In this case), initialized with that value. C's type suffixes may be used to control the size of numeric literals.
The problem is that nothing in Objective-C's world corresponds to a Bool!
. Thus, this declaration is not exposed to Objective-C. You need to declare this a plain Bool
if you want Objective-C to be able to see it.
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