Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/swift/19.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
j2objc无法调用在swift中返回JavaIoInputStream的方法_Swift_J2objc - Fatal编程技术网

j2objc无法调用在swift中返回JavaIoInputStream的方法

j2objc无法调用在swift中返回JavaIoInputStream的方法,swift,j2objc,Swift,J2objc,我的一个java类实现了两种方法: public OutputStream getOutputStream(){ return null; } public int getV(){ return 3; } 使用j2Objc转换后,我尝试在swift中调用这些方法: func test() { let i = ComExampleTestSharedMyClass() var v = d.getV() var s = d.getOutputStream(

我的一个java类实现了两种方法:

public OutputStream getOutputStream(){
    return null;
}

public int getV(){
    return 3;
}
使用j2Objc转换后,我尝试在swift中调用这些方法:

func test() {
    let i = ComExampleTestSharedMyClass()
    var v = d.getV()
    var s = d.getOutputStream()
}
实例化和getV()编译得很好,但是getOutputStream()没有消息:

ComExampleTestSharedMyClass has no member getOutputStream.
在MyClass.h中,我可以看到两种已翻译的方法:

- (jint)getV;
- (JavaIoOutputStream *)getOutputStream;
明显的区别在于返回的类型,它是jre_emul的一部分

出于测试目的,我在objective-C中做了一个测试(我的第一次尝试!):


它是用objective-C编译的,那么我能为swift做些什么呢?

好的,我被编译器消息愚弄了,它说类没有请求的方法,而实际上它是方法的返回类型 这是未知的


如果我在桥接头中添加#import“OutputStream.h”,它就会工作。

好的,我被编译器消息愚弄了,它说类没有请求的方法,而实际上,它是方法的返回类型 这是未知的

如果我在桥接头中添加#import“OutputStream.h”,它就会工作

#import "Configurator-Bridging-Header.h"

@implementation TestGetOutputStream

- (void) theTest{
    ComExampleTestSharedMyClass* i = [ComExampleTestSharedMyClass alloc];
    [i getOutputStream];
}
@end