If you just need to check an object's type, you can use the type check operator, is
, as in:
if myObject is UIView {
// do something
}
If you want to try to call a method on the object but you aren't sure of the class, downcast the object to the type you need, like this:
if let myView = myObject as? UIView {
myView.layer.backgroundColor = myColor
}