Reputation: 6413
Hey I got ConfigurationType protocol
protocol ConfigurationType {}
and my own cell class
class ConfigurableCell<T: ConfigurationType>: UITableViewCell {
func configure(with config: T) {}
}
All my cells inherit from ConfigurableCell and I want to create CellModules, which my tableView would use.
protocol CellModule {
associatedtype Config: ConfigurationType
associatedtype Cell: ConfigurableCell<Config>
var config: Config { get set }
}
extension CellModule {
init(_ config: Config) {
self.config = config
}
func dequeueCell(_ tableView: UITableView) -> UITableViewCell {
let cell = tableView.dequeueReusableCell() as Cell
cell.configure(with: config)
return cell
}
}
goal is to create module for cell like this
struct GoalTitleCellModule: CellModule {
typealias Cell = GoalTitleCell
var config: GoalTitleConfiguration
}
but xcode complain "Type 'GoalTitleCellModule' does not conform to protocol 'CellModule'".
What I'm doing wrong?
Upvotes: 0
Views: 135
Reputation: 447
Making CellModule protocol visible to Objective-C and changing GoalTitleCellModule type to class will solve your problem.
Take a look here: https://bugs.swift.org/browse/SR-55
Upvotes: 1