Reputation: 1517
I'm trying to pass a simple string from a Swift Controller to an Objective-C controller, but unfortunately it doesn't work.
Error I get:
Value of type 'EUIDViewController' has no member 'stringPassed'
Swift Code sending string
let pvc = EUIDViewController(nibName: "ScannerViewController", bundle: nil)
if isHasCameraPermission {
pvc.stringPassed = "test"
present(pvc, animated: true, completion: { _ in })
}
Objective-C code receiving the string
@property (strong, nonatomic) NSString* stringPassed;
- (void)viewDidLoad {
[super viewDidLoad];
[self initOCR];
NSLog(@"String: %@", self.stringPassed);
}
Update: I did #import "EUIDViewController.h" into the bridging-header
Upvotes: 1
Views: 1027
Reputation: 72460
You need to declare stringPassed
property in .h
means header file of that ViewController
.
@interface ViewController : UIViewController
@property (strong, nonatomic) NSString* stringPassed;
@end
Upvotes: 5