当我尝试添加桥以在 Objective-C 中使用 Swift 时出现消息错误。
这是我的代码:
import UIKit
@objc class ScanViewController : UIViewController, IRLScannerViewControllerDelegate
{
var scan: Int = 0 //FIXME:delegate to put in swift
var category: String = "" //FIXME:delegate to put in swift
...
这是我在 Swift 中的桥梁:
// Bridging.swift
// Created by OlostA on 10/06/2016.
import Foundation
import UIKit
@objc class Hello: NSObject {
func sayHello() {
print("Hi there!")
}
}
这是我的 Objective-C 文件:
#import "CategoryViewController.h"
#import "ScanViewController.swift"
#import "GoFact-Swift.h"
@interface CategoryViewController ()
@end
@implementation CategoryViewController
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
if ([[segue identifier] isEqualToString:@"yourSegueIdentifier"])
{
ScanViewController *destViewController = segue.destinationViewController;
destViewController.category = sender;
}
}
任何的想法?