2017-10-08 31 views
-2

私はテーブルビューを使用しようとしているとFUNCに:Cannot convert value of type 'IndexPath.Type' to expected argument type 'IndexPath'は、型の値が期待引数の型に「IndexPath.Type」に変換できません「IndexPath」

私のコードは次のとおりです:

cellForRowAt私はエラーを取得します
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { 
    let cellDish:DishTableViewCell = tableView.dequeueReusableCell(withIdentifier: "cellDish", for: IndexPath) as! DishTableViewCell  
    return cellDish 
} 
+1

for:indexPathです。 'IndexPath'の代わりに' indexPath'小文字の 'i'パラメータを使用してください。 – vacawama

+0

ありがとう!できます –

答えて

0

問題は、IndexPathパラメータです。

クラスを使用していますが、インスタンスは使用していません。正しい方法は:

func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { 
    let cellDish:DishTableViewCell = tableView.dequeueReusableCell(withIdentifier: "cellDish", for: indexPath) as! DishTableViewCell  
    return cellDish 
} 
関連する問題