You can add @objc to Swift properties or methods to make them accessibile from Objective-C code. What does this exactly mean? I just want a one liner for this question.
Asked
Active
Viewed 908 times
0
-
please see this question answer https://stackoverflow.com/questions/44390378/how-can-i-deal-with-objc-inference-deprecation-with-selector-in-swift-4/44391493#44391493 – Kiran Sarvaiya Feb 13 '18 at 05:35
2 Answers
2
The @objc attribute makes your Swift code available in Objective-C and the Objective-C runtime.
Explaination:
In some cases, you need finer grained control over how your Swift API is exposed to Objective-C. In that case, You can use the @objc(name) attribute to change the name of a class, property, method, enumeration type, or enumeration case declaration in your interface as it’s exposed to Objective-C code.
Check this: when to use @objc in swift code?

UGandhi
- 518
- 1
- 8
- 28
0
Most of the time it happens when you are sub classing a Swift class of Objective-C base class.The @objc attribute makes your Swift code available in Objective-C and the Objective-C runtime.

Rashed
- 2,349
- 11
- 26