1

当我运行我的应用程序并尝试按下按钮时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
}

我该如何解决我的问题?在另一个程序中,一切正常。

4

1 回答 1

0

我发现了我的错误!但是如果 DDPWNAGE 不询问错误日志说什么,就没有找到它。我忘记了 1 个 ID。现在一切正常

于 2015-04-20T18:50:56.527 回答