Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 2016-06-16 02:04:37.586 ParseStarterProject-Swift[1959:117839] *** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<ParseStarterProject_Swift.ViewController 0x7fcc9bc21f40> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key switch.'
- import UIKit
- func displayAlert(title: String, message: String) {
- let alert = UIAlertController(title: title, message: message, preferredStyle: UIAlertControllerStyle.Alert)
- alert.addAction(UIAlertAction(title: "OK", style: .Default, handler: { (action) in
- self.dismissViewControllerAnimated(true, completion: nil)
- }))
- self.presentViewController(alert, animated: true, completion: nil)
- }
- var activityIndicator: UIActivityIndicatorView = UIActivityIndicatorView()
- @IBOutlet weak var username: UITextField!
- @IBOutlet weak var password: UITextField!
- @IBOutlet weak var selector: UISwitch!
- @IBOutlet weak var mainButton: UIButton!
- @IBOutlet weak var alternateButton: UIButton!
- @IBAction func mainButton(sender: AnyObject) {
- if username == "" || password == "" {
- displayAlert("Error in form", message: "Please enter a username and a password")
- } else {
- activityIndicator = UIActivityIndicatorView(frame: CGRect(x: 0, y: 0, width: 50, height: 50))
- activityIndicator.center = self.view.center
- activityIndicator.hidesWhenStopped = true
- activityIndicator.activityIndicatorViewStyle = UIActivityIndicatorViewStyle.Gray
- view.addSubview(activityIndicator)
- activityIndicator.startAnimating()
- UIApplication.sharedApplication().beginIgnoringInteractionEvents()
- if selector.on == true {
- // Rider Sign Up
- let user = PFUser()
- user.username = username.text
- user.password = password.text
- user["type"] = "rider"
- user.signUpInBackgroundWithBlock({ (success, error) in
- self.activityIndicator.stopAnimating()
- UIApplication.sharedApplication().endIgnoringInteractionEvents()
- if success == true {
- // Sign Up Successful
- } else {
- if let errorString = error!.userInfo["error"] as? String {
- self.displayAlert("Failed SignUp", message: errorString)
- }
- }
- })
- } else {
- // Driver Sign Up
- let user = PFUser()
- user.username = username.text
- user.password = password.text
- user["type"] = "driver"
- user.signUpInBackgroundWithBlock({ (success, error) in
- self.activityIndicator.stopAnimating()
- UIApplication.sharedApplication().endIgnoringInteractionEvents()
- if success == true {
- // Sign Up Successful
- } else {
- if let errorString = error!.userInfo["error"] as? String {
- self.displayAlert("Failed SignUp", message: errorString)
- }
- }
- })
- }
- }
- }
- @IBAction func alternateButton(sender: AnyObject) {
- }
- override func viewDidLoad() {
- super.viewDidLoad()
- }
- override func didReceiveMemoryWarning() {
- super.didReceiveMemoryWarning()
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement