2016-04-09 29 views
-1

每次我得到這個錯誤我想加載一個特定的UIViewController應用程序終止錯誤由於NSUnknownKeyException

2016年4月9日20:48:02.183對myApp [91268:15399441] *終止應用程序由於 未捕獲的異常「NSUnknownKeyException」,原因: '[setValue:forUndefinedKey:]:此 類不是密鑰值編碼兼容的密鑰registerAction。' *第一擲調用堆棧:(0的CoreFoundation 0x000000010aaa6d85 exceptionPreprocess + 165 1 libobjc.A.dylib
0x000000010c84adeb objc_exception_throw + 48 2的CoreFoundation
0x000000010aaa69c9 - [NSException提高] + 9 3基金會
0x000000010ae7819b - [NSObject的(的NSKeyValueCoding )的setValue:forKey:] + 288 4的UIKit 0x000000010b461d0c - [UIViewController中的setValue:forKey:] + 88 5的UIKit 0x000000010b6987fb - [UIRuntimeOutletConnection連接] + 109 6
的CoreFoundation 0x000000010a9e0890 - [NSArray的 makeObjectsPerformSelector:] + 224 7的UIKit
0x000000010b6971de - [UINib instantiateWithOwner:選擇:] + 1864 8
的UIKit 0x000000010b4688d6 - [UIViewController中_loadViewFromNibNamed:束:] + 381 9的UIKit 0x000000010b469202 - [UIViewController中的loadView] + 178 10的UIKit
0x000000010b469560 - [UIViewController中loadViewIfRequired] + 138 11 的UIKit 0x000000010b469cd3 - [UIViewController的視圖] + 27 12的UIKit 0x000000010b33ffb4 - [一個UIWindow addRootViewControllerViewIfPossible] + 61 13的UIKit 0x000000010b34069d - [一個UIWindow _setHidden:強制:] + 282 14的UIKit 0x000000010b352180 - [一個UIWindow makeKeyAndVisible] + 42 15的UIKit
0x0000000 10b2c6ed9 - [UIApplication的 _callInitializationDelegatesForMainScene:transitionContext:] + 4131 16的UIKit 0x000000010b2cd568 - [UIApplication的_runWithMainScene:transitionContext:完成:] + 1769 17的UIKit 0x000000010b2ca714 - [UIApplication的workspaceDidEndTransaction:] + 188個18 FrontBoardServices 0x000000010e6db8c8 __FBSSERIALQUEUE_IS_CALLING_OUT_TO_A_BLOCK
+ 24個19 FrontBoardServices 0x000000010e6db741 - [FBSSerialQueue _performNext] + 178 20 FrontBoardServices 0x000000010e6dbaca - [FBSSerialQueue _performNextFromRunLoopSource] + 45 21的CoreFoundation 0x000000010a9cc301 CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION + 17 22的CoreFoundation爲0x0 00000010a9c222c __CFRunLoopDoSources0 + 556 23的CoreFoundation 0x000000010a9c16e3 __CFRunLoopRun + 867 24的CoreFoundation
0x000000010a9c10f8 CFRunLoopRunSpecific + 488 25的UIKit
0x000000010b2c9f21 - [UIApplication的_run] + 402 26的UIKit
0x000000010b2cef09 UIApplicationMain + 171 27對myApp
0x000000010a70dfb2主+ 114 28 libdyld。 dylib
0x000000010dc6292d start + 1 29 ???
0x0000000000000001 0x0 + 1)libC++ abi。dylib:與類型NSException(LLDB)的 未捕獲的異常

的UIViewController的==>裏面的內容終止

import UIKit 

class signUpPage: UIViewController { 

@IBOutlet var emailTextField: UITextField! 

@IBOutlet var passTextField: UITextField! 
override func viewDidLoad() { 
    self.viewDidLoad() 
} 
override func didReceiveMemoryWarning() { 
    self.didReceiveMemoryWarning() 
} 

@IBAction func registerAction(sender: AnyObject) { 
    let email = self.emailTextField.text 
    let pass = self.passTextField.text 
    if (email != "" && pass != ""){ 

     firebase_ref.createUser(email, password: pass, withValueCompletionBlock: { (error, results) in 
      if (error == nil){ 
       firebase_ref.authUser(email, password: pass, withCompletionBlock: { (error, authData) in 
        if (error == nil){ 
         NSUserDefaults.standardUserDefaults().setValue(authData.uid, forKey: "uid") 
         print("Account created Successfully ") 
         self.dismissViewControllerAnimated(true, completion: nil) 
        }else{ 
         print(error.localizedDescription) 
        } 
       }) 
      }else{ 
       print(error.localizedDescription) 
      } 
     }) 


    }else{ 
     let alert = UIAlertController(title: "Error", message: "Enter an email and password", preferredStyle: .Alert) 
     let okAction = UIAlertAction(title: "ok", style: .Default, handler: nil) 
     alert.addAction(okAction) 
     self.presentViewController(alert, animated: true, completion: nil) 
    } 
} 

@IBAction func cancleAction(sender: AnyObject) { 

    self.dismissViewControllerAnimated(true, completion: nil) 
} 

} 在此先感謝您的幫助:)

+0

我我只定義了其中的2個,我用它們都是XD 1.emailTextField 2.passTextField @El Captain –

回答

-1
import UIKit 

class signUpPage: UIViewController { 

@IBOutlet var emailTextField: UITextField! 

@IBOutlet var passTextField: UITextField! 
override func viewDidLoad() { 
self.viewDidLoad() 
} 
override func didReceiveMemoryWarning() { 
self.didReceiveMemoryWarning() 
} 

@IBAction func registerAction(sender: AnyObject) { 
let email = self.emailTextField.text 
let pass = self.passTextField.text 
if (email != "" && pass != ""){ 

    firebase_ref.createUser(email, password: pass, withValueCompletionBlock: { (error, results) in 
     if (error == nil){ 
      firebase_ref.authUser(email, password: pass, withCompletionBlock: { (error, authData) in 
       if (error == nil){ 
        if (authData.uid != nil) { 
    NSUserDefaults.standardUserDefaults().setValue(authData.uid, forKey: "uid") 
} 
        print("Account created Successfully ") 
        self.dismissViewControllerAnimated(true, completion: nil) 
       }else{ 
        print(error.localizedDescription) 
       } 
      }) 
     }else{ 
      print(error.localizedDescription) 
     } 
    }) 


}else{ 
    let alert = UIAlertController(title: "Error", message: "Enter an email and password", preferredStyle: .Alert) 
    let okAction = UIAlertAction(title: "ok", style: .Default, handler: nil) 
    alert.addAction(okAction) 
    self.presentViewController(alert, animated: true, completion: nil) 
} 
} 

@IBAction func cancleAction(sender: AnyObject) { 

self.dismissViewControllerAnimated(true, completion: nil) 
} 
+0

我應該在哪寫這段代碼:) @va ibby –

+0

代碼爲您編輯 – vaibby

0

看起來你沒有連接到你的xib的IBAction registerAction。

轉到您的xib這個UIViewController,按住Control並點擊並從按鈕拖動到文件的所有者,您會看到一個彈出菜單並帶有IBAction列表。可以從列表中選擇正確的連接按鈕。

此外,如果您可能希望將發件人定義爲類型而不是AnyObject。

enter image description here

,或者您沒有對文件的所有者連接到廈門國際銀行

點擊正確的類,並確保正確的類是身份檢查:

enter image description here

相關問題