UIViewAnimating
already has a method to start the animation after a delay, you should use this one instead :
startAnimation(afterDelay: 0.3)
If you insist on using perform(_:with:afterDelay:)
you can use it like so:
perform(NSSelectorFromString("startAnimation"), with: nil, with: 0.3)
But keep in mind that you loose compiler safety with this approach, and if you make a typo in your selector your app will crash.
Also, your code is weird because UIViewController
doesn't conform to UIViewAnimating
, so unless you implemented the protocol yourself (which would be quite unusual), it's not going to work. It's more likely that you have a method called startAnimation
in your view controller and that the Swift migrator mistakenly added the reference to UIViewAnimating
. In which case the correct code would be:
perform(#selector(self.startAnimation), with: nil, afterDelay: 0.3)