harthoo
harthoo

Reputation: 813

Objc code cannot find Bool variable defined in swift

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'

Upvotes: 20

Views: 8367

Answers (1)

matt
matt

Reputation: 535128

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.

Upvotes: 36

Related Questions