0

So what I am trying to do is make it easy for me to implement many custom UITableViewCells on one tableView, to do this I wanted to create a protocol that would facilitate filling out the function:

- (void)registerClass:(nullable Class)cellClass forCellReuseIdentifier:(NSString *)identifier

my protocol so far looks like this:

protocol TableViewCellClassReportingProtocol: class {
    func reuseID() -> String
}

extension TableViewCellClassReportingProtocol {
    static func classObject() -> AnyClass? {
        return self.class
    }
}

however I am having issues with getting the class type even thought I specify that this protocol must be implemented by a class. Any suggestions, I may be approaching this the wrong way

CWineland
  • 615
  • 7
  • 18

1 Answers1

0

So this was close to the right answar and let me both elaborate and give credit to Charles A.

dynamicType is part of the answar! great call!

the function implamintation also had to change, because of subclassing and static really meaning "class final"

Protocol for class method

the override points must be

override class func reuseID() -> String
Community
  • 1
  • 1
CWineland
  • 615
  • 7
  • 18