2017-02-08 5 views
-2

Alles ist in Ordnung, aber wenn ich auf dem Tableview und ging zum Thema:swift3 thread1: Signal SIGABRT, Beenden app aufgrund nicht abgefangene Ausnahme ‚NSUnknownKeyException‘

thread1:Signal SIGABRT, '[<UIViewController 0x7fc3c0c0b730> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key lastName.' 

AppDelegate.swift und der Fehler ging auf der Linie : class AppDelegate: UIResponder, UIApplicationDelegate

import UIKit 

@UIApplicationMain 
class AppDelegate: UIResponder, UIApplicationDelegate { 

    var window: UIWindow? 

    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { 
     // Override point for customization after application launch. 
     return true 
    } 

    func applicationWillResignActive(_ application: UIApplication) { 
    // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. 
    // Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game. 
} 

func applicationDidEnterBackground(_ application: UIApplication) { 
    // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. 
    // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 
} 

func applicationWillEnterForeground(_ application: UIApplication) { 
    // Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background. 
} 

func applicationDidBecomeActive(_ application: UIApplication) { 
    // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. 
} 

func applicationWillTerminate(_ application: UIApplication) { 
    // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 
} 
} 

DetailsViewController.swift, nach dem Tableview klicken sie auf Detailansicht und zeigen die Details der Daten in der Tabelle

0 gehen

TableViewController.swift, und eine weitere Frage, Was ist @IBAction func myUnwindAction(segue:UIStoryboardSegue) über?

import UIKit 

class TableTabViewController: UIViewController,UITableViewDataSource,UITableViewDelegate { 


    @IBOutlet weak var dataTable: UITableView! 
    @IBOutlet var barButton : UIBarButtonItem? 


    override func viewDidLoad() { 
     super.viewDidLoad() 
     dataTable.delegate=self; 
     dataTable.dataSource=self; 

    } 

    override func didReceiveMemoryWarning() { 
     super.didReceiveMemoryWarning() 

    } 


    @IBAction func myUnwindAction(segue: UIStoryboardSegue) 
    { 

     if let temp = segue.source as? NewStudentViewController{ 
      if (temp.exitBool != true){ 
       StudentDataBase.instance.addStudent(st: temp.st!); 
       dataTable.reloadData(); 
      } 
     } 

    } 



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

     return StudentDataBase.instance.getNumberOfStudents(); 
    } 


    public func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { 

     let cell=UITableViewCell(); 
     cell.textLabel?.text=StudentDataBase.instance.getStudentByIndex(index: indexPath.row).getFullName(); 
     return cell; 
    } 


    func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { 
     performSegue(withIdentifier: "details", sender: StudentDataBase.instance.getStudentByIndex(index: indexPath.row)); 
    } 


    override func prepare(for segue: UIStoryboardSegue, sender: Any?){ 
     if let detailsController=segue.destination as? DetailsViewController{ 
      detailsController.st=sender as? Student; 
     } 


    } 


    @IBAction func editTableView (_ sender:UIBarButtonItem) 
    { 
     if dataTable.isEditing{ 
      //listTableView.editing = false; 
      dataTable.setEditing(false, animated: true); 
      barButton?.style = UIBarButtonItemStyle.plain; 
      barButton?.title = "Edit"; 
      //listTableView.reloadData(); 
     } 
     else{ 
      //listTableView.editing = true; 
      dataTable.setEditing(true, animated: true); 
      barButton?.title = "Done"; 
      barButton?.style = UIBarButtonItemStyle.done; 
      //listTableView.reloadData(); 
     } 
    } 

    func tableView(_ tableView: UITableView, commit editingStyle: UITableViewCellEditingStyle, forRowAt indexPath: IndexPath) 
    { 
     if editingStyle == UITableViewCellEditingStyle.delete{ 
      if(StudentDataBase.instance.deleteStudent(ids: StudentDataBase.instance.getStudentByIndex(index: indexPath.row).id!)) 
      { 
       self.editTableView(barButton!); 
       dataTable.reloadData(); 
      } 

     } 

    } 
} 

Vielen Dank!

Antwort

0

Sie haben die benutzerdefinierte View-Controller-Unterklasse in Interface Builder falsch festgelegt. (Vielleicht hast du die Klasse umbenannt?) Also fällt es wieder auf die Eltern UIViewController. Beachten Sie die Warnung "Unbekannte Klasse" in der Debugger-Ausgabe. Der Absturz erfolgt aufgrund einer Steckdose, die zwischen einer PhoneNumber-Eigenschaft und einer Ansicht eingerichtet wurde. Da die Controller-Unterklasse jedoch nicht richtig eingestellt ist, versucht das System, die PhoneNumber Steckdose auf UIViewController zu finden und stürzt ab.

Um zu beheben, legen Sie den richtigen Unterklassennamen in Interface Builder fest.

+0

Ich habe das Projekt umbenannt, und davor habe ich keine Probleme gesehen. Ich habe den DetaislViewController überprüft und festgestellt, dass die Steckdose phoneNumber nicht verbunden war, behoben, aber immer noch das Problem. –

+0

Wenn Sie das Projekt umbenannt haben, stellen Sie sicher, dass das "Modul" richtig eingestellt ist. Es ist direkt unter dem Klassennamen des Controllers in Interface Builder. –

+0

Hallo, wie ich das Problem der Telefonnummer behoben habe, da ich keine richtige Verbindung zwischen Phonennummer und einer Ansicht hatte. danach kam es zu einem anderen problem auf lastName, könntest du mir bitte sagen wie es geht? –

Verwandte Themen