Hello, updated Swift 3, now there is an error on Selector (), how to fix it? 
Closed due to the fact that off-topic participants Kromster , 0xdb , Grundy , Edward , Eugene Krivenja Sep 14 '18 at 8:20 .
It seems that this question does not correspond to the subject of the site. Those who voted to close it indicated the following reason:
- “Questions asking for help with debugging (“ why does this code not work? ”) Should include the desired behavior, a specific problem or error, and a minimum code for playing it right in the question . Questions without an explicit description of the problem are useless for other visitors. See How to create minimal, self-sufficient and reproducible example . " - Kromster, 0xdb, Grundy, Edward, Eugene Krivenja
|
2 answers
cool why do you have this line at all, it does nothing - there is no selector there.
resetButton.addTarget(self, action: #selector(someMethod), for: .touchUpInside) - Oh, I was upset and I see nothing, I started to convert, but he showed me 3540 errors) - Leci
|
The compiler explicitly tells you that it cannot call the constructor of a Selector structure without parameters. The constructor can take a string parameter explicitly:
resetButton.addTarget(self, action: Selector("resetAction"), for: .touchUpInside) , but in this case, the compiler will ask to use a special expression of the language to create selectors:
resetButton.addTarget(self, action: #selector(resetAction), for: .touchUpInside) Using this expression is safer than the line (the compiler will generate a compilation error if you seal it), and it is also more convenient to change it when refactoring.
|