Reputation: 1635
I'm trying to implement a segue from one view to another. It works fine from one swift class to another, but from a swift class to an objective-c class, I get the error:
Use of undeclared type 'ReordViewController'
Code:
if (templateList?.objectAtIndex(indexPath.row) as NSString != "Story") {
var dvc : TemplateViewController = self.storyboard?.instantiateViewControllerWithIdentifier("TemplateViewController") as TemplateViewController
dvc.tweet = templateList?.objectAtIndex(indexPath.row) as NSString
self.navigationController?.pushViewController(dvc, animated: true)
}
else {
var dvc : RecorderViewController = self.storyboard?.instantiateViewControllerWithIdentifier("RecorderViewController") as RecorderViewController
self.navigationController?.pushViewController(dvc, animated: true)
}
Edit:
To clarify, TemplateViewController is in Swift and RecorderViewController is in Objectivce-C.
Upvotes: 3
Views: 572
Reputation: 438467
You have to create a bridging header (it will often automatically prompt you to create one when you include Objective-C class in Swift project or vice versa) and then make sure to manually include a #import
line for your Objective-C class header in the bridging header file:
#import "RecorderViewController.h"
See Swift and Objective-C in the Same Project discussion.
Upvotes: 3