Swift SIGABRT错误(没有错误的连接)

时间:2016-06-21 03:23:21

标签: ios swift sigabrt

请耐心等待,我对Swift来说是全新的。我正试图通过从ClassList UITableView中选择一个单元来转向另一个UIViewController,但无论我尝试什么,我似乎总是得到相同的Sigabrt错误。我做了很多研究,而且我听到的大部分内容都说它来自主故事板上的剩余/未使用的连接,但我检查过,我没有。所有我得到的错误都是lldb,当我输入bt时我无法理解目标c输出。如有必要,我会发布错误输出,但现在这是我的代码(对不起,这么久我不想冒险留下重要的东西)

import UIKit
import Firebase
import FirebaseDatabase

var classes = [String]()
var CurrentClass = ""

class TeacherHomeScreen : UIViewController, UITableViewDelegate, UITableViewDataSource{


@IBOutlet var ClassList: UITableView!

override func viewDidLoad() {
    super.viewDidLoad()
    if NSUserDefaults.standardUserDefaults().objectForKey(CurrentUser) != nil{
        classes = NSUserDefaults.standardUserDefaults().objectForKey((FIRAuth.auth()?.currentUser?.email)!)! as! [String]
    }
    else{
        classes = [""]
    }
    viewDidAppear(true)
}

func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
    self.performSegueWithIdentifier("SelectedClassSegue", sender: indexPath)
}

func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int{
    return classes.count
}

func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell{
    let ClassCell = tableView.dequeueReusableCellWithIdentifier("ClassCell", forIndexPath: indexPath)         
    ClassCell.textLabel?.text = classes[indexPath.row]
   // ClassCell.ProjectButton.tag = indexPath.row
    return ClassCell
}

override func viewDidAppear(animated: Bool) {
    ClassList.reloadData()
}

func tableView(tableView: UITableView, commitEditingStyle editingStyle: UITableViewCellEditingStyle, forRowAtIndexPath indexPath: NSIndexPath){
    if editingStyle == UITableViewCellEditingStyle.Delete{
        classes.removeAtIndex(indexPath.row)
        NSUserDefaults.standardUserDefaults().setObject(classes, forKey: CurrentUser)
        ClassList.reloadData()
    }
}

override func didReceiveMemoryWarning() {
    super.didReceiveMemoryWarning()
}

这是我不断出错的地方

override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
    if segue.identifier ==  "TeacherLogOut"{
        CurrentUser = ""
        try! FIRAuth.auth()!.signOut()
    }
    if segue.identifier ==  "SelectedClassSegue"{
        _ = segue.destinationViewController as! SelectedClass

    }

 }  
}

更新

现在当我在单击一个单元格时加载此代码时没有任何反应,它只是突出显示并且没有出现segue。这是代码

import Foundation

import UIKit
import Firebase
import FirebaseDatabase


var CurrentClass = ""

var classes = [String]()

class TeacherHomeScreen : UIViewController, UITableViewDelegate, UITableViewDataSource{


@IBOutlet var ClassList: UITableView!

override func viewDidLoad() {
    super.viewDidLoad()

    if NSUserDefaults.standardUserDefaults().objectForKey(CurrentUser) != nil{

        classes = NSUserDefaults.standardUserDefaults().objectForKey((FIRAuth.auth()?.currentUser?.email)!)! as! [String]
    }
    else{
        classes = [""]
    }
}

func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int{

    return classes.count
}

func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell{

    let ClassCell = tableView.dequeueReusableCellWithIdentifier("ClassCell", forIndexPath: indexPath)         
    ClassCell.textLabel?.text = classes[indexPath.row]

   // ClassCell.ProjectButton.tag = indexPath.row

    return ClassCell
    }
override func viewDidAppear(animated: Bool) {
    ClassList.reloadData()
}

func tableView(tableView: UITableView, commitEditingStyle editingStyle: UITableViewCellEditingStyle, forRowAtIndexPath indexPath: NSIndexPath){

    if editingStyle == UITableViewCellEditingStyle.Delete{

        classes.removeAtIndex(indexPath.row)

        NSUserDefaults.standardUserDefaults().setObject(classes, forKey: CurrentUser)

        ClassList.reloadData()

    }

}

override func didReceiveMemoryWarning() {
    super.didReceiveMemoryWarning()
}

override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
    if segue.identifier ==  "TeacherLogOut"{

        CurrentUser = ""
        try! FIRAuth.auth()!.signOut()
    }
   // if segue.identifier ==  "SelectedClassSegue"{

       // _ = segue.destinationViewController as! SelectedClass

    }

}

1 个答案:

答案 0 :(得分:1)

将发件人Indexpath更改为nill

 <div>
My name is <?php echo "$_SESSION['name']"; ?>
</div>

顺便说一下,prepareForSegue中有一些未使用的变量,这不会导致任何错误,但是有一个不使用的变量,所以我想建议: -

func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
    self.performSegueWithIdentifier("SelectedClassSegue", sender: nil)
}