2016-06-10 41 views
1

我有一個消息錯誤,當我嘗試添加橋在Objective-C中使用Swift。錯誤消息'Expected;在頂級聲明器'未知類型名稱導入'與橋使用Swift Objective-C

這裏是我的代碼:

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 
... 

這是我在斯威夫特橋:

// 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; 
    } 
} 

任何想法?

回答

5

您必須刪除

#import "ScanViewController.swift" 

它應該是那麼好。

+0

非常感謝你,它的工作原理! – Claudio

相關問題