Reputation: 99
I am trying to get a value from a Swift function of a class I made. The Swift file is recognized and properly included in a Objective C project via the MyProdName-Swift.h header. I can instanciate it, but I am not able to get a String from a function.
Swift class:
@objc public class Test : NSObject {
@objc func getTest () -> NSString{
return "tested"
}
}
Objective C class:
Test *test = [Test new];
NSString *testDummy = test.getTest();
In the last line I get "Called object type 'NSString *' is not a function or function pointer".
So obviously I am making some basic mistake, please point me to it.
Upvotes: 3
Views: 347
Reputation: 130222
You're trying to call the method in Objective C using Swift method call syntax. You should be doing this:
NSString *testDummy = [test getTest];
Upvotes: 7