I am declaring a selector and want to pass a label object as the parameter and not able to do so.
Below is my code:
public func animateLabelText(label: UILabel) {
caDisplayLink = CADisplayLink(target: self, selector: #selector(changeLabelText(label: label)))
}
@objc private func changeLabelText(label: UILabel) {
// Do something
}
I am seeing this error - Argument of '#selector' does not refer to an '@objc' method, property, or initializer.
How do I pass the parameter to selector?
The signature should be as following
public func animateLabelText(label: UILabel) {
caDisplayLink = CADisplayLink(target: self,
selector: #selector(changeLabelText(_:)))
}
@objc private func changeLabelText(_ label: UILabel) {
// Do something
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.