Bear with me please I am completely new to Swift.I am trying to segue to another UIViewController by selecting a cell from ClassList UITableView, but no matter what I try I always seem to get the same Sigabrt error. I did a lot of research and most of what I heard said that it came from leftover/unused connections on the main storyboard but I checked and I have none. All I'm getting for my error is lldb and I can't understand the objective c output when I put in bt. I will post the error output if necessary but for now this is my code (sorry its so long I didn't want to risk leaving something important out)
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()
}
This is where I keep getting there error
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
if segue.identifier == "TeacherLogOut"{
CurrentUser = ""
try! FIRAuth.auth()!.signOut()
}
if segue.identifier == "SelectedClassSegue"{
_ = segue.destinationViewController as! SelectedClass
}
}
}
Aucun commentaire:
Enregistrer un commentaire