我正在尝试从一种观点到另一种观点实施segue。从一个swift类到另一个,它都能正常工作,但是从swift类到Objective-c类,我得到了错误:
使用未声明的类型'ReordViewController'
码:
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)
}
编辑:
要澄清的是,TemplateViewController在Swift中,而RecorderViewController在Objectivce-C中。
您必须创建一个桥接标头(当您在Swift项目中包含Objective-C类时,它通常会自动提示您创建一个,反之亦然),然后确保为#import
桥接中的Objective-C类标头手动添加一行头文件:
#import "RecorderViewController.h"
请参阅同一项目中的Swift和Objective-C讨论。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句