I use Typhoon and I need selector for injection property
definition.injectProperty(Selector("viewModel"), with: self.viewModel.inviteViewModel())
var viewModel: AuthViewModel!
Argument of '#selector' cannot refer to a property
You have a misunderstanding of what can be passed into
#selector(). You should definitely read the StackOverflow questions that Eric D posted:
Overview on what you can use
#selector() for: Understanding Swift 2.2 Selector Syntax - #selector()
The reason why you can not pass a Swift property in to
Selector availability: The method referenced by the selector must be exposed to the ObjC runtime. This is already the case if it's in a class that (ultimately) inherits from NSObject, but if it's in a pure Swift class you'll need to preface that method's declaration with @objc. Remember that private symbols aren't exposed to the runtime, too — your method needs to have at least internal visibility.
- Referenced from @selector() in Swift?
In short, you can't pass in a
var and you need to pass a function that the Objective-C runtime is aware of. Either it is an Objective-C method, or it is a Swift method marked as