当我运行我的应用程序并尝试按下按钮时DONE
,我看到:
Thread 1 EXC_BAD_INSTRUCTION.
这是代码:
import UIKit
class DeveloperViewController: UITableViewController {
@IBAction func cancelToPlayersViewController(segue:UIStoryboardSegue){
}
@IBAction func saveDeveloperDetail(segue:UIStoryboardSegue){
if let developerDetailsViewController = segue.sourceViewController as? DeveloperDetailsViewController{
developers.append(developerDetailsViewController.developer) //Here Thread 1
let indexPath = NSIndexPath(forRow: developers.count-1, inSection: 0)
tableView.insertRowsAtIndexPaths([indexPath], withRowAnimation: .Automatic)
}
}
var developers: [Developers] = developersData
// MARK: - Table view data source
override func numberOfSectionsInTableView(tableView: UITableView) -> Int {
// #warning Potentially incomplete method implementation.
// Return the number of sections.
return 1
}
override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return developers.count
}
override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath)
-> UITableViewCell {
let cell = tableView.dequeueReusableCellWithIdentifier("DeveloperCell", forIndexPath: indexPath)
as! UITableViewCell
let developer = developers [indexPath.row] as Developers
cell.textLabel?.text = developer.name
cell.detailTextLabel?.text = developer.type
return cell
}
我该如何解决我的问题?在另一个程序中,一切正常。