I have my app set for crossing over between Swift and Obj-C. Define Module is set to yes, I've imported the -Swift.h file into the viewcontroller I am working on. I am now trying to present the swift view controller from the objective-c view controller.
Here's some code that works, the swift view controller is presented and the background color is red:
BulkProcessController* myBulkProcessController = [self.storyboard instantiateViewControllerWithIdentifier:@"bulkProcessController"];
myBulkProcessController.view.backgroundColor = [UIColor redColor];
[self presentChildViewController:myBulkProcessController];
However, in swift view controller I have a enum and var property set:
class BulkProcessController: UIViewController {
enum ProcessType {
case AddContact
case DeleteContact
}
var myProcessType: ProcessType = .AddContact
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
}
Back to the instantiating part. If I change the code to this:
BulkProcessController* myBulkProcessController = [self.storyboard instantiateViewControllerWithIdentifier:@"bulkProcessController"];
ProcessType thisProcessType = [[[notification userInfo] objectForKey:@"Process Type"] intValue];
myBulkProcessController.myProcessType = ADDCONTACTS;
myBulkProcessController.view.backgroundColor = [UIColor redColor];
[self presentChildViewController:myBulkProcessController];
The line: myBulkProcessController.myProcessType = ADDCONTACTS; throws an error [NOTE: I know ADDCONTACTS is not a proper value, it is AddContact, that's a separate issue]. The error is myProcessType not found on object of type BulkProcessController.
And yet, if I put a break point right after instantiating the view controller I can see the property in the debug console:
Is this an issue of where the property is there but not available to Obj-C? I thought importing the -Swift.h file resolved that. If this is the case, how do I access the swift file properties from Obj-C? Or am I doing it wrong in the Swift file?
Any help would be appreciated.