iosobjective-cswiftj2objc

Objective C class method call in Swift


j2objc created a class method declaration in the header file as follows:

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

I am trying to call this from swift code.

Could anybody direct to me on how to do.

EDIT#1:

Matt, I added the labels as follows:

    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)

I am getting error:

'startWithNSString(_:withNSString:withInt:withInt:withInt:)' has been renamed to 'start(with:with:with:with:with:)'


Solution

  • This is what Xcode 9 give me in the auto complete:

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

    Assuming you have variables called portNumber, width and height of the appropriate type in Swift. (Are they all integers?)