This is my function:
func get<T: Decodable>(type: T.Type, subclass: T){}
I have an array of random objects. The objects that conform to the protocol Decodable should be able to call this function. This is what I mean:
class MasterClass{
func get<T: Decodable>(type: T.Type, subclass: T){}
}
class A: MasterClass, Decodable{}
class B: MasterClass{}
func x(){
let array: [MasterClass] = [A(), B()]
for obj in array{
if let conformer = obj as? Decodable{
obj.get(type: type(of: conformer), subclass: conformer)
//doesn't work
}
}
}
I do not get this to work, but I can not understand why.
Cannot invoke 'get' with an argument list of type '(type: Decodable.Type, subclass: Decodable)'