What is @selector() in Swift and how to use it with NSTimer?
Hello everyone! I'm a beginner iOS developer transitioning from Objective-C to Swift. Previously in Objective-C, I actively used @selector() for working with timers and target-action, for example:
```objc
[NSTimer scheduledTimerWithTimeInterval:1.0
target:self
selector:@selector(updateTimer:)
userInfo:nil
repeats:YES];
```
Now I'm trying to do the same in Swift, but the compiler complains when I write:
```swift
let timer = Timer.scheduledTimer(timeInterval: 1.0,
target: self,
selector: @selector(updateTimer:),
userInfo: nil,
No answers yet.
Log in to leave an answer