DenTelezhkin/DTCollectionViewManager

Generic parameter 'T' could not be inferred.

Sweeper777 opened this issue · 1 comments

After I updated to the swift 3 version (5.0.0-beta.2), this error shows up:

Generic parameter 'T' could not be inferred.

What I'm trying to do with my collection view is that I want to show a bunch of colors for the user to choose from. Here is the cell class:

class ColorCell: UICollectionViewCell, ModelTransfer {
    typealias ModelType = UIColor

    func update(with model: UIColor) {
        layer.cornerRadius = self.w / 2
        layer.borderWidth = 1.5
        self.backgroundColor = model
    }
}

Then, I wrote a method with this signature:

func selectedColor(_ cell: ColorCell, color: UIColor, indexPath: IndexPath) {

}

So far so good. But the error appears on this line:

manager.didSelect(ColorCell.self, ColorSelectorController.selectedColor)

It says that T cannot be inferred! But obviously T is ColorCell!

Try removing typealias ModelType = UIColor, this should not be needed, as type is gathered automatically from update(with:) method.

As for second issue, method pointers were removed in DTCollectionViewManager 5.0.0, because it was hard maintaining two event systems. You can react to cell selection with following:

manager.didSelect(ColorCell.self) { cell, color, indexPath in
    print("Selected \(color) at \(indexPath)")
}

Hope this resolves your issue.