Colin
Colin

Reputation: 4135

Make A Call In Objective-C To A Method Using Swift String

I have a class method in Swift:

import Foundation

public class MyClass : NSObject{
    class func registerDevice(userId uId: String, deviceId dId: String, pushServiceToken token: String) -> Void{ /*...*? }
}

I'm then trying to call that function from Objective-C, but I'm borking something. Here's what I'm trying:

[MyClass registerDevice: @"user id" deviceId: [UIDevice currentDevice].identifierForVendor.UUIDString pushServiceToken: registrationToken];

...but I'm getting the error:

"No known class method for selector 'registerDevice::deviceId:pushServiceToken:'"

What's the right way to make this call?

Upvotes: 1

Views: 178

Answers (1)

Avi
Avi

Reputation: 7552

You can find out how Xcode translates the Swift signature to Objective-C by checking the auto-generated <module>-Swift.h file. <module> will be the name of the app, if you haven't defined a module (and/or you're not building a framework).

To find the file (it doesn't appear in your project sources), hit cmd-shift-O and enter -Swift.h.

EDIT: In this case, the method was named "registerDeviceWithUserId".

Upvotes: 1

Related Questions