【问题标题】:iOS - Xcode Thread 1 EXC_BAD_INSTRUCTIONiOS - Xcode 线程 1 EXC_BAD_INSTRUCTION
【发布时间】:2015-04-20 18:23:39
【问题描述】:

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

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

【问题讨论】:

  • 完成按钮连接到什么?它与您显示的代码有什么关系?
  • 错误日志说明了什么?
  • 当你按下完成后,你会回到表格视图
  • 致命错误:在展开可选值时意外发现 nil

标签: ios swift exc-bad-instruction


【解决方案1】:

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-05-13
    相关资源
    最近更新 更多