iOS - Xcode Thread 1 EXC_BAD_INSTRUCTION

时间:2015-04-20 18:23:40

标签: ios swift exc-bad-instruction

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

如何解决我的问题? 在另一个程序中都有效。

1 个答案:

答案 0 :(得分:0)

我发现了我的错误! 但是如果DDPWNAGE没有问错误日志说什么,就没有找到它。 我忘了1个身份证。 现在所有的工作