Я изучаю Swift 4 с Xcode 9 и пытался создать TableView с 50 ячейками.
В ячейке 1 "1"
в ячейке 2 "2"
и т. д.
Вот мой код:
import UIKit
class ViewController: UIViewController, UITableViewDataSource, UITableViewDelegate{
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return 50
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = UITableViewCell(style: UITableViewCellStyle.default, reuseIdentifier: "Cell")
cell.textLabel?.text = String[indexPath.row + 1]
}
}
Теперь компилятор говорит в этой строке cell.textLabel?.text = String[indexPath.row + 1]
«Элемент Instance Member» не может использоваться в строке типа «
Как сделать 50 ячеек с содержанием от 1 до 50?