Swift中的目标C类方法调用

时间:2018-07-17 02:37:45

标签: ios objective-c swift j2objc

j2objc在头文件中创建了一个类方法声明,如下所示:

(void)startWithNSString:(NSString *)folderPath
    withNSString:(NSString *)pushyToken
    withInt:(jint)port
    withInt:(jint)width
    withInt:(jint)height

我正试图通过快速代码来调用它。

有人可以指导我怎么做吗。

EDIT#1:

马特,我添加了以下标签:

    let screenSize = UIScreen.main.bounds
    let screenWidth:Int32 = Int32(screenSize.width)
    let screenHeight:Int32 = Int32(screenSize.height)

    let pushyToken = UserDefaults.standard.object(forKey: "pushyToken") as? String ?? String()
    SocketClient.startWithNSString("", withNSString:pushyToken,
                                         withInt:8000, withInt:screenWidth, withInt:screenHeight)

我遇到错误:

  

'startWithNSString(_:withNSString:withInt:withInt:withInt :)'已经   重命名为'start(with:with:with:with:with:with:)'

1 个答案:

答案 0 :(得分:1)

这是Xcode 9在自动完成中给我的:

object.abc(with: "Folder path", with: "Token", with: portNumber, with: width, with: height)

假设您在Swift中有适当类型的变量portNumberwidthheight。 (它们都是整数吗?)