1

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

1 Answer 1

5

You need to declare stringPassed property in .h means header file of that ViewController.

@interface ViewController : UIViewController

@property (strong, nonatomic) NSString* stringPassed;

@end
Sign up to request clarification or add additional context in comments.

2 Comments

Oh thanks! I feel stupid... will mark your answer as the right one when I may!
@Isabelle Welcome mate :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.