Is There Any Reason to Use Selectors in Swift?

Viewed 546

Specifically, when a task can be complemented with or without selectors, is there any (objective) reason to prefer one way over the other?

For instance, an NSTimer can run a method on an interval in two ways:

A) Using Selectors:

let timer = Timer.scheduledTimer(timeInterval: 1, target: self, selector: #selector(timerAction()), userInfo: nil, repeats: true)

dynamic func timerAction() {
    print("foo")    
}

B) Without Selectors:

let timer = Timer.scheduledTimer(withTimeInterval: 1, repeats: true) { _ in
    self.timerAction()
}

func timerAction() {
    print("foo")
}

Both versions are entirely functional, so is there any (objective) reason to prefer one over the other?

1 Answers
Related