Reputation: 189
I am trying to convert my Objective-C code into Swift.
So I have 2 classes, class A
- converted to Swift, class B
still in Objective-C.
In my Swift class I have a method setName(_ name: String)
. But when I try to call it in Obj-C it sees it with with
keyword, like:
setNameWithName
Can I somehow avoid it and just call [method setName: @"Name"]
without using with
keyword?
Upvotes: 2
Views: 251
Reputation: 54706
You can specify how Obj-C types should see an @objc
Swift function by supplying the desired function signature in the @objc()
declaration.
@objc(setName:)
func setName(_ name: String) {
}
Upvotes: 2