Avatar
Avatar
omochimetaru
そんな話があって当時、そうだなあと納得したんだけど、検索してもみつからね〜
class UICell {} func _dequeue(_ type: UICell.Type) -> UICell { print(type) // MyCellが出てこない fatalError() } func dequeue<Cell: UICell>(_ type: UICell.Type = Cell.self) -> Cell { _dequeue(Cell.self) as! Cell } class MyCell: UICell {} class MyCell2: UICell {} func cell(for row: Int) -> UICell { let cell: UICell if Bool.random() { cell = dequeue(MyCell.self) } else { cell = dequeue(MyCell2.self) } return cell } cell(for: 0) おぼろげな記憶から思い出してみたんですがこんな感じだったかも?