函数didSelectRowAtIndexPath
与未捕获的异常崩溃并导致class AppDelegate: UIResponder, UIApplicationDelegate{
与Thread1:信号SIGABRT错误
我认为这是代表们的错误发布。关于如何处理这个问题的任何想法?
import UIKit
class UnitTableViewController: UIViewController, UITableViewDataSource, UITableViewDelegate, UIActionSheetDelegate {
let cellID = "cellID"
@IBOutlet var tableView: UITableView!
override func viewDidLoad() {
super.viewDidLoad()
tableView.dataSource = self
tableView.delegate = self
}
func numberOfSectionsInTableView(tableView: UITableView) -> Int {
return 1
}
func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return 2
}
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
var cell = tableView.dequeueReusableCellWithIdentifier(cellID) as UITableViewCell!
if !(cell != nil){
cell = UITableViewCell(style:.Default, reuseIdentifier: cellID)
}
if indexPath.row == 0
{
cell.textLabel?.text = "2016"
}
else {
cell.textLabel?.text = "2017"
}
return cell;
}
func tableView(tableView: UITableView, titleForHeaderInSection section: Int) -> String? {
return String (format: "Please select year of study", section + 1)
}
func tableView(tableView: UITableView, titleForFooterInSection section: Int) -> String? {
return String (format: "Thankyou for your selection", section + 1)
}
func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
switch (indexPath.row) {
case 0:
[self.performSegueWithIdentifier("2015Segue'", sender: self)]
case 1:
[self.performSegueWithIdentifier("2016Segue'", sender: self)]
default:
break;
}
// NSLog("Row %ld selected on Section %ld", indexPath.row + 1, indexPath.section + 1)
tableView.deselectRowAtIndexPath(indexPath, animated: true)
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
}
}