Unable to access Swift var from Objective-C View controller - iOS

I have an application with two Objective-C and Swift view controllers. I programmatically open a Swift-based controller from one of my Objective-C view controllers. The problem is that I cannot access Swift variables from my Objective-C code.

My Swift Code:

@IBOutlet weak var profPicture: UIImageView!
@IBOutlet weak var profVerified: UIImageView!
@IBOutlet weak var profName: UILabel!
var passedUser:PFUser!

My Objective-C code:

MyProfileViewController *screen = [[MyProfileViewController alloc] initWithNibName:@"Main" bundle:nil];
self.dataPass = screen;
dataPass.profName.text = @"";
screen.modalTransitionStyle = UIModalTransitionStyleCoverVertical;
[self presentViewController:screen animated:YES completion:nil];

I can access @ properties such as IBOutlets, but I cannot access and edit var objects.

I do this because I want to transfer data to a Swift-based view controller from an Objective-C-based view controller when I present a Swift-based view controller.

Why can't I access var objects?

Here is the error I get:

enter image description here

The error is as follows:

'passUser' 'MyProfileViewController *'

, .

+4
2

public.

internal, , . Obj-C .

+4

ObjectiveC, Swift ObjectiveC.

public , enum , [project] -Swift.h.

 var firstQuestion: AnswerResult = AnswerNone

:

var firstQuestion: AnswerResult!
+2

Source: https://habr.com/ru/post/1614154/


All Articles