In swift 4 we are starting to get warnings when using @objc func, and I get that it's actually better to avoid it. I need to create a precise timer for animations, like CADisplayLink. The problem is that CADisplayLink is using #selector, and to use it I need to create @objc func. Is there any alternative for it in Swift 4?
Asked
Active
Viewed 124 times
0
-
What kind of warning do you get? There's nothing wrong with declaring functions as `@objc` if you need them to be visible to Objective-C. – Ole Begemann Jun 09 '17 at 19:56
-
`The use of Swift 3 @objc inference in Swift 4 mode is deprecated. Please address deprecated @objc inference warnings, test your code with “Use of deprecated Swift 3 @objc inference” logging enabled, and disable Swift 3 @objc inference.` – Damian Dudycz Jun 09 '17 at 19:58
-
1See https://stackoverflow.com/a/44391389/116862 – Ole Begemann Jun 09 '17 at 19:59
-
`@objc` inference being deprecated doesn't mean there's anything deprecated or wrong about exposing certain functions to ObjC. Especially if you need to use patterns/APIs (like `CADisplayLink`) that require ObjC selectors. What the deprecation is about is being clearer when you intend to expose things to ObjC, as opposed to paying a performance cost for implicitly exposing everything. – rickster Jun 10 '17 at 21:09