2017-10-15 2 views
0

の設定ねえ、私はConfigurationTypeプロトコルスウィフト - 異なるセルを同じよう

protocol ConfigurationType {} 

と私自身のセルクラス

class ConfigurableCell<T: ConfigurationType>: UITableViewCell { 
    func configure(with config: T) {} 
} 

はすべての私の細胞はConfigurableCellから継承してしまったと私はCellModulesを作成したい、私のtableViewが使用します。

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 
    } 
} 

目標は、この

struct GoalTitleCellModule: CellModule { 
    typealias Cell = GoalTitleCell 
    var config: GoalTitleConfiguration 
} 

が、Xcodeのは、 "プロトコルのCellModule」に準拠していないタイプ 'GoalTitleCellModule' を" 文句のようにセルのためのモジュールを作成することです。私が間違ってやっている何

enter image description here

答えて

1

Objective-CにCellModuleプロトコルを表示させ、GoalTitleCellModuleタイプをクラスに変更すると、問題が解決されます。

ここをクリックしてください:https://bugs.swift.org/browse/SR-55

関連する問題