Use undeclared type error: How to compare object with class type?

Viewed 325

How to compare object with AnyClass generic type:

I want to compare an object with the type of class and the class name should be passed as an argument.

func checkGeneric(className: AnyClass) {
    let object = UIViewController()
    if (object is className) { // Use of undeclared type `className`
        print(className)
    }
}

checkGeneric(className: UIViewController.self)
3 Answers
Related