2016-04-09 5 views
-1

ich diesen Fehler jedes Mal, wenn ichApp Abschlussfehler aufgrund NSUnknownKeyException

2016-04-09 20 einen spezifischen UIViewController laden möge: 48: 02,183 myApp [91268: 15399441] * Beenden app aufgrund für die nicht abgefangene Ausnahme 'NSUnknownKeyException', Grund: '[setValue: forUndefinedKey:]: Diese Klasse ist für den Schlüssel registerAction nicht Schlüsselcodierkonform.' * Erstschlingen Aufrufliste: (0 Corefoundation 0x000000010aaa6d85 exceptionPreprocess + 165 1 libobjc.A.dylib
0x000000010c84adeb objc_exception_throw + 48 2 Corefoundation
0x000000010aaa69c9 - [NSException erhöhen] + 9 3 Foundation
0x000000010ae7819b - [NSObject (NSKeyValueCoding setValue): forKey:] + 288 4 UIKit 0x000000010b461d0c - [UIViewController setValue: forKey:] + 88 5 UIKit 0x000000010b6987fb - [UIRuntimeOutletConnection verbinden] + 109 6
Corefoundation 0x000000010a9e0890 - [NSArray makeObjectsPerformSelector:] + 224 7 UIKit
0x000000010b6971de - [UINib instantiateWithOwner: Optionen:] + 1864 8
UIKit 0x000000010b4688d6 - [UIViewController _loadViewFromNibNamed: bundle:] + 381 9 UIKit 0x000000010b469202 - [UIViewController Loadview] + 178 10 UIKit
0x000000010b469560 - [UIViewController loadViewIfRequired] + 138 11 UIKit 0x000000010b469cd3 - [UIViewController Ansicht] + 27 12 UIKit 0x000000010b33ffb4 - [UIWindow addRootViewControllerViewIfPossible] + 61 13 UIKit 0x000000010b34069d - [UIWindow _setHidden: forcierte:] + 282 14 UIKit 0x000000010b352180 - [UIWindow makeKeyAndVisible] + 42 15 UIKit
0x0000000 10b2c6ed9 - [UIApplication _callInitializationDelegatesForMainScene: transitionContext:] + 4131 16 UIKit 0x000000010b2cd568 - [UIApplication _runWithMainScene: transitionContext: Fertigstellung:] + 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 Haupt + 114 28 libdyld. Dylib
0x000000010dc6292d Start + 1 29 ???
0x0000000000000001 0x0 + 1) libC++ abi.dylib: endet mit abgefangene Ausnahme vom Typ NSException (LLDB)

den Inhalt innerhalb des 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) 
} 

} Vielen Dank im Voraus für Ihre Hilfe :)

+0

I habe nur 2 davon definiert und ich habe sie beide benutzt XD 1.emailTextField 2.passTextField @El Captain –

Antwort

-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

wo soll ich diesen Code schreiben :) @va ibby –

+0

Code für Sie bearbeitet – vaibby

0

Sieht so aus, als ob Sie die IBAction registerAction nicht mit Ihrer xib verbunden haben.

Gehen Sie zu Ihrem XIB für diesen UIViewController, klicken Sie mit gedrückter Strg-Taste und ziehen Sie von der Schaltfläche zum Eigentümer der Datei. Daraufhin wird ein Menü mit einer Liste Ihrer IBActions angezeigt. Kann den richtigen aus der Liste auswählen, um die Schaltfläche zu verbinden.

Auch wenn Sie den Absender als einen Typ anstelle von AnyObject definieren möchten.

enter image description here

Oder Sie haben nicht die richtige Klasse mit dem xib verbunden

Klicken Sie auf Datei-Besitzer und stellen Sie sicher, die richtige Klasse in Identity Inspector ist:

enter image description here

Verwandte Themen