1

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?

1
  • 1
    No, it is, because you use the wrong selector. This is the "method name", regardless of its parameter types. Likely you have to add UserId or so after registerDevice. Commented Jun 23, 2016 at 19:31

1 Answer 1

1

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".

Sign up to request clarification or add additional context in comments.

1 Comment

Great answer, not only for pointing me in the right direction, but also for the handy tip on the keyboard shortcut! It turns out, the function was renamed to "registerDeviceWithUserId".

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.