2017-02-08 3 views
-2

すべては大丈夫ですが、私はのtableViewをクリックすると、スレッドに行ってきました:swift3スレッド1:信号SIGABRTは、キャッチされない例外によりにアプリを終了「NSUnknownKeyException」

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

AppDelegate.swift、およびエラーがライン上に行ってきました: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、後のことはdetailViewに移動し、テーブル内のデータの詳細を表示する必要がありますテーブルビューをクリックし

import UIKit 

class DetailsViewController: UIViewController { 

    var st:Student? 


    @IBOutlet weak var stName: UILabel! 
    @IBOutlet weak var lastName: UILabel! 
    @IBOutlet weak var phoneNumber: UILabel! 
    @IBOutlet weak var studentId: UILabel! 

    override func viewDidLoad() { 
     super.viewDidLoad() 

     stName.text=st?.fName; 
     lastName.text=st?.lName; 
     phoneNumber.text=st?.phoneNum; 
     studentId.text=st?.id; 

    } 

    override func didReceiveMemoryWarning() { 
     super.didReceiveMemoryWarning() 
     // Dispose of any resources that can be recreated. 
    } 

} 

TableViewController.swiftともう1つ質問あり、@IBAction func myUnwindAction(segue:UIStoryboardSegue)について

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(); 
      } 

     } 

    } 
} 

ありがとうございました!

答えて

0

Interface BuilderでカスタムView Controllerサブクラスを正しく設定していません。 (おそらく、あなたはクラスの名前を変更しましたか?)それで、それは親のUIViewControllerに戻ります。 デバッガの出力で「Unknown class」という警告が表示されます。 プロパティとビューの間にコンセントが設定されているためにクラッシュが発生しましたが、コントローラーサブクラスが正しく設定されていないため、コンセントがUIViewControllerに見つかり、クラッシュします。

修正するには、Interface Builderで正しいサブクラス名を設定します。

+0

私はプロジェクトの名前を変更しましたが、その前に問題は見られませんでした。私はDetaislViewControllerをチェックし、アウトレットphoneNumberが接続されていない、固定されていることを発見しましたが、まだ問題があります。 –

+0

プロジェクトの名前を変更した場合は、「モジュール」を正しく設定してください。 Interface Builderのコントローラのクラス名の下にあります。 –

+0

こんにちは、私は電話番号と電話番号の間に適切な接続がないので電話番号の問題を解決しました。その後、それはlastNameの別の問題になった、あなたはどうすればいいか教えてくれますか? –

関連する問題