I've seen a lot of questions and answers on this, but none of them seem to cover or solve my situation.
I have a project originally written in Objc, and now, one by one, I'm replacing all classes with Swift 4 syntax.
My problem is, that I cannot access swift properties in my Objective C files.
This is what I have so far:
I have this one swift file, called MessagesViewController.swift that starts as follows:
@objc class MessagesViewController: UIViewController, UITableViewDataSource, UITableViewDelegate{
@objc var mailboxNumber:NSNumber = 0
...
Then, in there is the objc class "MessagesBoxController" that needs to access mailboxNumber in the prepareForSegue method:
So, in MessagesBoxController.h I import the generated interface header:
#import "myProduct-Swift.h"
and in MessagesBoxController.m I have this boilerplate method:
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
MessagesViewController *destViewController = segue.destinationViewController;
NSIndexPath *selectedIndexPath = [_tv indexPathForSelectedRow];
destViewController.mailboxNumber =selectedIndexPath.row+1;
}
So, the Swift class "MessagesViewController" is recognised fine; no complaints by the compiler whatsoever. Its properties though are not exposed:
auto complete doesn't suggest mailboxNumber and upon building the project, I get the error
"Property 'mailboxNumber' not found on object of type 'MessagesViewController *'"
What part is missing to make this work?