【发布时间】:2015-11-23 05:55:41
【问题描述】:
我正在执行苹果文档中编写的相同步骤。但我无法访问目标 c 文件中的 swift 类。
代码:
Swift 文件
import Foundation
import UIKit
@objc class checkk : UIViewController {
func alertView ()
{
let al = UIAlertView(title: "HeLLo", message: "Working", delegate: nil, cancelButtonTitle: "OK", otherButtonTitles: "ww", "sdd")
al.show()
}
}
Objective C 文件
#import "ViewController.h"
#import "SwiftIntoObjectiveC-Bridging-Header.h" // automatically generated by Xcode. Nothing is written in this.
@interface ViewController ()
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
checkk *ck =[checkk new]; // error : use of undeclared identifier check.
// Do any additional setup after loading the view, typically from a nib.
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
- (IBAction)Click:(id)sender {
}
@end
错误: 使用未声明的标识符检查。
【问题讨论】:
-
尝试使用 checkk *ck = [[checkk alloc] init];
-
你的错误意味着你是
#import任何地方的checkk类 -
你忘记在 ViewController 中实现
#import "checkk-Swift.h"
标签: ios objective-c swift