I created a simple test to show what I am trying to do, sometimes we need to use some code that need to feed a selector and that selector need a function that have @objc, what I want and trying to do is deform the shape of code that I could bypass using @objc in front of function or more perfectly even deforming using selector also, basically I want avoid having selector or @objc in my codes, here is the example:
class MyTestAppClass {
@objc func test() {
print("Hello, world!")
}
}
let test = NSMenuItem(title: "Test", action: #selector(MyTestAppClass.test), keyEquivalent: "t")
as you can see the NSMenuItem needs a selector and I have to responding it with a func that has @objc, so all my goal is avoiding selector in first place and if that is not possible trying to avoid using @objc, How can i do this? Is there any way for bypass those? Also this question is not trying to learn about basic of selector or @objc, it simply tries to find hacks for reaching the goal of avoiding them. I want my code looks more swiftier after bypassing #selector or @objc. Is there any option or space in coding that allow us for some maneuvers?