I have two protocols A and B where B inherits from A.
protocol A { }
protocol B: A { }
And I have a utility class which has function called add whose parameter should conform to the protocol A:
class Utility {
func add<T:A>(t:T.Type,param:T){
....
}
}
Then I have a test class which creates object of Utility and calls its function add which accepts a parameter of type B (class object which implements B):
class Test {
var util: Utility
init() {
util = Utility()
}
func addItem(data:B){
util.add(B.self,param: data) // This line produces Cannot invoke add with argument list
} // of type (B.Protocol,param:B)
}
What am I doing wrong?