For example I have this method in swift:
@objc class MyClass: NSObject
....
@objc class func viewWithIndex(index: Int, str: String) {
println(index, str)
}
then i wanna call that method in my objective-c class, and i was expecting as simple as this call [MyClass viewWithIndex:10 str:@"string"]; but it doesn't work.
How do i call it? Please help.
Note: I have already a working swift function call to objective-c [MyClass showSomething]; so that means i have successfully setup necessary settings to bridge classes. Only the function that has two of more parameters is my problem. :)
Solved:
I dont know what i happened but i just restarted my mac and removed objc and it worked with the call [MyClass viewWithIndex:10 str:@"string"];. I remember reading in documentation.
Migrating Your Objective-C Code to Swift
- To be accessible and usable in Objective-C, a Swift class must be a descendant of an Objective-C class or it must be marked @objc.
No Known class method for selector viewWithIndex:str#import YOUR_PROJECT_NAME-Swift.h?