0

I am new to Xcode and currently I am trying to follow a tutorial on how to build a login and sign up page using Firebase. I hit a bit of road block atm, because after adding some code for the image capture for the user profile image, the app comes up with the following error message and I have no idea how to fix it, so could someone body please explain to me what I need to do or point me in the right direction, thanks a lot!

Error message from console:

2017-06-13 15:47:05.450 ToDoList[992] [Firebase/Analytics][I-ACS023012] Firebase Analytics enabled 2017-06-13 15:47:10.104832 ToDoList[992:265128] Unknown class SignUpViewController in Interface Builder file. 2017-06-13 15:47:10.116920 ToDoList[992:265128] * Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[ setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key countryTextField.' * First throw call stack: (0x1862d01c0 0x184d0855c 0x1862cfe88 0x186cd71a0 0x18c477864 0x18c61b558 0x1861efdc4 0x18c619f2c 0x18c47a838 0x18c24ca58 0x18c118260 0x18c118190 0x18cadbf24 0x18c462f18 0x18c484384 0x18c487250 0x18c20b070 0x19a0b36e0 0x18c8e8144 0x18c8d91d8 0x18c8d8fe0 0x18c8d92b0 0x18c14d9a0 0x18c14d920 0x18c137dd0 0x18c14d20c 0x18c14cd34 0x18c147f7c 0x18c118a44 0x19a07a35c 0x18c905ea8 0x18c8ff910 0x18627e278 0x18627dbc0 0x18627b7c0 0x1861aa048 0x187c2d198 0x18c183818 0x18c17e550 0x100079d28 0x18518c5b8) libc++abi.dylib: terminating with uncaught exception of type NSException

My code so far:

import UIKit

class SignUpViewController: UIViewController, UIImagePickerControllerDelegate, UINavigationControllerDelegate {

@IBOutlet weak var userImageView: UIImageView!

@IBOutlet weak var usernameTextField: UITextField!

@IBOutlet weak var emailTextField: UITextField!

@IBOutlet weak var passwordTextField: UITextField!

@IBOutlet weak var countryTextField: UITextField!


override func viewDidLoad() {
    super.viewDidLoad()

    // Do any additional setup after loading the view.
}

// Choose image for the profile picture
@IBAction func choosePicture(sender: Any) {

    let pickerController = UIImagePickerController()
    pickerController.delegate = self
    pickerController.allowsEditing = true

    let alertController = UIAlertController(title: "Add a Picture", message: "Choose From", preferredStyle: .actionSheet)

    let cameraAction = UIAlertAction(title: "Camera", style: .default) { (action) in
        pickerController.sourceType = .camera
        self.present(pickerController, animated: true, completion: nil)
    }

    let photoLibraryAction = UIAlertAction(title: "Photo Library", style: .default) { (action) in
        pickerController.sourceType = .photoLibrary
        self.present(pickerController, animated: true, completion: nil)
    }

    let savedPhotosAction = UIAlertAction(title: "Saved Photos Album", style: .default) { (action) in
        pickerController.sourceType = .savedPhotosAlbum
        self.present(pickerController, animated: true, completion: nil)
    }

    let cancelAction = UIAlertAction(title: "Cancel", style: .cancel, handler: nil)

    alertController.addAction(cameraAction)
    alertController.addAction(photoLibraryAction)
    alertController.addAction(savedPhotosAction)
    alertController.addAction(cancelAction)

    present(alertController, animated: true, completion: nil)

}
// Add image to the profile image circle
func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [String : Any]) {
    if let image = info[UIImagePickerControllerOriginalImage] as? UIImage
    {
        userImageView.image = image
    }
    else
    {
        //Error message
    }
}




@IBAction func signUpAction(_ sender: Any) {
}

}

1 Answers1

0

After looking into other people's problem regarding NSUnknownKeyException, it's actually quite difficult to pin down on what the specific solutions are. But I have tried the following method and it worked for me:

Sometimes this has to do with your "Inherit From Target" That value has to be set. With single target apps you can just select Inherit From Target. If you have more then one target select the desired target.

Link to my solution: What does this mean? "'NSUnknownKeyException', reason: … this class is not key value coding-compliant for the key X"