Я пытаюсь создать табличный вид, в котором у него есть список блюд с разделами, и когда мы выбираем строку, она должна перейти к новому представлению таблицы, которые состоят из списка популярных ресторанов, которые обслуживают эту определенную пищу ,Проблемы с таблицей в swift iOS
Я создал табличный вид с разделами, но мое приложение падает, когда я дойду до конца списка. Я добавил код ниже с моментальным снимком представления таблицы и ошибки.
@IBOutlet weak var dishtable: UITableView!
@IBOutlet weak var namlbl: UILabel!
var Dishes = ["POPULAR Dishes": ["Biryani", "Tandori Chicken","Butter Chicken", "Vada Pav"],"A": ["Aloo baingan", "Aloo ki Tikki", "Amritsari fish"], "B": ["Baigan bharta", "Biryani"]];
override func viewDidLoad() {
super.viewDidLoad()
self.dishtable.registerClass(UITableViewCell.self, forCellReuseIdentifier: "cell")
dishtable.dataSource = self
dishtable.delegate = self
// Do any additional setup after loading the view.
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
override func prefersStatusBarHidden() -> Bool {
return true
}
let sections:Array<AnyObject> = ["POPULAR Dishes","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"]
var usernames = [String]()
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell{
let cellID = "cell"
let cell: UITableViewCell = self.dishtable.dequeueReusableCellWithIdentifier(cellID) as! UITableViewCell
println("value : \(indexPath.section)")
println("value 1: \(indexPath.row)")
cell.textLabel!.text = Dishes[sections[indexPath.section] as! String]![indexPath.row]
return cell
}
func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int{
println("Dishes section count : \(section)")
return Dishes.count
}
func numberOfSectionsInTableView(tableView: UITableView) -> Int{
return 27
}
func tableView(tableView: UITableView, didEndDisplayingCell cell: UITableViewCell, forRowAtIndexPath indexPath: NSIndexPath) {
}
func tableView(tableView: UITableView,
sectionForSectionIndexTitle title: String,
atIndex index: Int) -> Int{
return index
}
func tableView(tableView: UITableView,
titleForHeaderInSection section: Int) -> String?{
return self.sections[section] as? String
}
Это скриншот для табличного вида.
Это скриншот ошибки, когда я прокрутите вниз до нижней части представления таблицы.
Это скриншот консоли для одной и той же ошибки.
Пожалуйста, дайте мне знать, как мы можем добавить функцию поиска в виде таблицы.