Reputation: 548
I can't figure out how to reference a Swift VC from an Objective C VC in a mixed language project. Here is Objective C code:
#import "NamesVC."
... ([segue.identifier isEqualToString:@"peopleSegue"]){
NamesVC *vc = segue.destinationViewController;
vc.selEntity = @"People";
vc.delegateMethod= @"Admin";
}
Bridging Header: Version10-Bridging-Header.h
#ifndef Version10_Bridging_Header_h
#define Version10_Bridging_Header_h
#import "AppDelegate.h"
#import "AdminTVC.h"
How do you import
by Swift VC into the Obj C class?
Upvotes: 0
Views: 1648
Reputation: 69
For anyone not finding a solution changing
"MyApp-Swift.h" to <MyApp-Swift.h>
in my objective c .m file that I wanted to reference my swift class
Upvotes: 1
Reputation: 9609
Importing Swift into Objective-C
You should import the Swift code from that target into any Objective-C .m file within that target using this syntax and substituting the appropriate name:
#import "NamesVC.h"
Upvotes: 0
Reputation: 72460
Import ProjectModuleName-swift.h
header inside your .m
file where you want to access Swift controller like this.
#import "ProjectModuleName-Swift.h"
After that you are able to access NamesVC
inside your Objective c ViewController
.
For more about this read Apple documentation on Swift and Objective-C in the Same Project
, inside this doc read about Importing Swift into Objective-C
Upvotes: 2