How to pass a Swift type as a method argument?
You have to use a generic function where the parameter is only used for type information so you cast it to T: func doSomething<T>(_ a: Any, myType: T.Type) { if let a = a as? T { //… } } // usage doSomething(“Hello World”, myType: String.self) Using an initializer of the type T You don’t … Read more