How to suppress selector warning in Swift
Issue #777
Sometimes we need to use dynamic selector and that triggers warning in Swift
1 | Selector("updateWithCount:") // Use '#selector' instead of explicitly constructing a 'Selector' |
In ObjC we can use clang macro to suppress, like below
1 |
|
But in Swift, we can just use a dummy NSObject that has the needed methods, like
1 | final class Dummy: NSObject { |
#selector
is just a safer way to construct Selector, they all yield same result as String
1 | Selector("updateWithCount:") // updateWithCount: |
Updated at 2021-02-18 10:11:13