I want to be able to store a class as a variable, so I can call class methods out of it later, something like this:
class SomeGenericItem: NSObject
{
var cellClass: AnyClass
init(cellClass: AnyClass)
{
self.cellClass = cellClass
}
func doSomething(p1: String, p2: String, p3: String)
{
self.cellClass.doSomething(p1, p2: p2, p3: p3)
}
}
class SomeClass: NSObject
{
class func doSomething(p1: String, p2: String, p3: String)
{
...
}
}
I want to be able to say something like:
let someGenericItem = SomeGenericItem(cellClass: SomeClass.self)
someGenericItem.doSomething("One", p2: "Two", p3: "Three")
What I'm trying to figure out is:
1) How would a protocol be defined so I could call class func doSomething?
2) What would the declaration of cellClass need to be?
3) What would the call look like?