Objective-C类不能看到Swift类的功能

时间:2018-06-11 18:45:52

标签: ios objective-c swift

我在Swift类中有一个函数,我想从Objective-C类调用它。我已经将Swift类声明为Objective-C类中的实例变量,但我似乎无法在该变量上调用Swift类中的方法。以下是一些示例代码:

PhotoViewController.swift:

@objc class PhotoViewController: UIViewController {
    // other methods and variables

    postViewController = // defined
    postViewController.ingestViewController = self

    @objc public func submit(image: UIImage) {
        // does stuff
    }
}

PostViewController.h:

@class PhotoViewController;

@interface PostViewController : UIViewController
@property (nonatomic, strong) PhotoViewController *ingestViewController;
@end

PostViewController.m:

#import "MyProject-Swift.h"
@class PhotoViewController;

@interface PostViewController ()

@end

@implementation PostViewController

// other code

- (void)_done {
    [self.ingestViewController submit:self.scan];
}
@end

我继续收到错误:No visible @interface for 'PhotoViewController' declares the selector 'submit:'。我也尝试将PhotoViewController公开,并没有解决我的问题。

0 个答案:

没有答案