I am converting an older application from Objective-C to Swift. In the objective c code their is a line that type casts a UIView to a UIButton. Here it is..
if ([((UIButton *)[self.view viewWithTag:1030]) isSelected]) {
//do something
}
Now when converting it to Swift I did this...
if ((self.view.viewWithTag(1025) as? UIButton).selected == true) {
//do something
}
Now I get no errors. But when I run the application in Swift I get a fatal error saying it unwrapped a nil value. This is happening because you cannot typecast a view as a UIButton becuase it is not the subclass view. But in Objective-c the cast works. So now how do I convert a view to a button in Swift? Thanks in advance.