one error in my last row of my code

Hello,


what means expected ',' seperator? I have tihs error in my last row (76)


i can chance my code but everytime that error is at the end of my code!!


mport UIKit
class RegisterPageViewController: UIViewController {
   
    @IBOutlet weak var userEmailTextField: UITextField!
    @IBOutlet weak var userPasswordTextField: UITextField!
    @IBOutlet weak var userRepeatPasswordTextField: UITextField!
   
    override func viewDidLoad() {
        super.viewDidLoad()
       
    }
    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
    }
    @IBAction func registerButtonTapped(sender: AnyObject) {
       
        let userEmail = userEmailTextField.text;
        let userPassword = userPasswordTextField.text;
        let userRepeatPassword = userRepeatPasswordTextField.text;
    }
   
       
        func displayMyAlertMessage(userMessage:String) {
           
        if((userEmail.isEmpty || userPassword.isEmpty || userRepeatPassword.isEmpty) {
        displayMyAlertMessage("All fields are required")
        return {
           
        if(userPassword != userRepeatPassword) {
        displayMyAlertMessage("Password do not match")
            return }
       
        let myUrl = NSURL(string: "www.2in1courier/twoinone_userLoin");
        let request = NSMutableURLRequest(URL: myUrl!);
        request.HTTPMethod = "POST";
        let postString = "email=\(userEmail)&password=\(userPassword)";
        request.HTTPBody = postString.dataUsingEncoding(NSUTF8StringEncoding);
   
       
        let task = NSURLSession.sharedSession().dataTaskWithRequest(request) {
        data, response, error in
       
        if error != nil {
        println("error=\(error)")
        return
   
        }
           
        var err: NSError?
        var json = NSJSONSerialization.JSONObjectWithData(data, options: .MutableContainers, error: &err) as? NSDictionary
       
        if let parseJSON = json {
            var resultValue = parseJSON["status"] as? String
            println("result: \(resultValue)") }
       
        var isUserRegistred:Bool = false;
        if (resultValue=="Success") { isUserRegistred = true
       
        }
           
        var messageToDisplay:String = parseJSON["message"] as String!;
        if(!isUserRegistred) {
           
        messageToDisplay = parseJSON["message"] as String!;
           
        }
            dispatch_async(dispatch_get_main_queue()) {
           
            var myAlert = UIAlertController(title: "Alert", message: messageToDisplay, preferredStyle: UIAlertControllerStyle.Alert)
            let okAction = UIAlertAction(title: "OK", style: UIAlertActionStyle.Default) {
            action in
            self.dismissViewControllerAnimated(true, completion: nil)
            }
            myAlert.addAction(okAction)
            self.presentViewController(myAlert, animated: true, completion: nil)
}

I think I fixed all the bugs but the code can still contain semantic errors. There were lots of missing {}, many superfluous ; some wrongly places variable declarations, some wrong method headers and a pre Swift 2 error handling. No guarantee that it will work but at least it now shows no remaining errors:


import UIKit


class RegisterPageViewController: UIViewController {


    @IBOutlet weak var userEmailTextField: UITextField!
    @IBOutlet weak var userPasswordTextField: UITextField!
    @IBOutlet weak var userRepeatPasswordTextField: UITextField!


    var userEmail = ""
    var userPassword = ""
    var userRepeatPassword = ""


    override func viewDidLoad() {
        super.viewDidLoad()


    }
    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
    }
    @IBAction func registerButtonTapped(sender: AnyObject) {


        userEmail = userEmailTextField.text!
        userPassword = userPasswordTextField.text!
        userRepeatPassword = userRepeatPasswordTextField.text!
    }




    func displayMyAlertMessage(userMessage:String) {


        if userEmail.isEmpty || userPassword.isEmpty || userRepeatPassword.isEmpty {
            displayMyAlertMessage("All fields are required")
            return
        }


        if userPassword != userRepeatPassword {
            displayMyAlertMessage("Password do not match")
            return
        }


        let myUrl = NSURL(string: "www.2in1courier/twoinone_userLoin")
        let request = NSMutableURLRequest(URL: myUrl!)
        request.HTTPMethod = "POST"
        let postString = "email=\(userEmail)&password=\(userPassword)"
        request.HTTPBody = postString.dataUsingEncoding(NSUTF8StringEncoding)


        _ = NSURLSession.sharedSession().dataTaskWithRequest(request) {
            data, response, error in


            if error != nil {
                print("error=\(error)")
                return
            }


            let json =  try! NSJSONSerialization.JSONObjectWithData(data!, options: .MutableContainers) as? NSDictionary


            if let parseJSON = json {
                let resultValue = parseJSON["status"] as? String
                print("result: \(resultValue)")


                var isUserRegistred:Bool = false
                if resultValue=="Success" {
                    isUserRegistred = true
                }


                var messageToDisplay:String = parseJSON["message"] as! String!
                if(!isUserRegistred) {
                    messageToDisplay = parseJSON["message"] as! String!
                }


                dispatch_async(dispatch_get_main_queue()) {
                    let myAlert = UIAlertController(title: "Alert", message: messageToDisplay, preferredStyle: UIAlertControllerStyle.Alert)
                    let okAction = UIAlertAction(title: "OK", style: UIAlertActionStyle.Default) {
                        action in
                        self.dismissViewControllerAnimated(true, completion: nil)
                    }
                    myAlert.addAction(okAction)
                    self.presentViewController(myAlert, animated: true, completion: nil)
                }
            }
        }
    }
}

many thanks.


know i have only the error in row 1: missing argument for parameter 'error' in call.


and also i have it to write an ';' after try!


import UIKit
class RegisterPageViewController: UIViewController {
    @IBOutlet weak var userEmailTextField: UITextField!
    @IBOutlet weak var userPasswordTextField: UITextField!
    @IBOutlet weak var userRepeatPasswordTextField: UITextField!
    var userEmail = ""
    var userPassword = ""
    var userRepeatPassword = ""
    override func viewDidLoad() {
        super.viewDidLoad()
    }
    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
    }
    @IBAction func registerButtonTapped(sender: AnyObject) {
        userEmail = userEmailTextField.text!
        userPassword = userPasswordTextField.text!
        userRepeatPassword = userRepeatPasswordTextField.text!
    }
    func displayMyAlertMessage(userMessage:String) {
        if userEmail.isEmpty || userPassword.isEmpty || userRepeatPassword.isEmpty {
            displayMyAlertMessage("All fields are required")
            return
        }
        if userPassword != userRepeatPassword {
            displayMyAlertMessage("Password do not match")
            return
        }
        let myUrl = NSURL(string: "www.2in1courier/twoinone_userLoin")
        let request = NSMutableURLRequest(URL: myUrl!)
        request.HTTPMethod = "POST"
        let postString = "email=\(userEmail)&password=\(userPassword)"
        request.HTTPBody = postString.dataUsingEncoding(NSUTF8StringEncoding)
         _ = NSURLSession.sharedSession().dataTaskWithRequest(request) {
            data, response, error in
            if error != nil {
                print("error=\(error)")
                return
            }
            let json = try!; NSJSONSerialization.JSONObjectWithData(data!, options: .MutableContainers) as? NSDictionary
            if let parseJSON = json {
                let resultValue = parseJSON["status"] as? String
                print("result: \(resultValue)")
                var isUserRegistred:Bool = false
                if resultValue=="Success" {
                    isUserRegistred = true
                }
                var messageToDisplay:String = parseJSON["message"] as! String!
                if(!isUserRegistred) {
                    messageToDisplay = parseJSON["message"] as! String!
                }
                dispatch_async(dispatch_get_main_queue()) {
                    let myAlert = UIAlertController(title: "Alert", message: messageToDisplay, preferredStyle: UIAlertControllerStyle.Alert)
                    let okAction = UIAlertAction(title: "OK", style: UIAlertActionStyle.Default) {
                        action in
                        self.dismissViewControllerAnimated(true, completion: nil)
                    }
                    myAlert.addAction(okAction)
                    self.presentViewController(myAlert, animated: true, completion: nil)
                }
            }
        }
    }
}

Oh, are you using Xcode 6.4? I made the changes in Xcode7 with the changed Swift syntax.

yes Xcode 6.4.


you mean about this is the error?


it's better when i upgrade? I find Xcode 7 beta 6 on the developer site. I'ts that the right?


If you are not directly before a release yes I think Xcode7 beta 6 is the better choice. Swift 2 has some important changes like the handling of errors. Your remaining error comes from me changing to Swift 2 error handling (The try!).

>it's better when i upgrade?

Not if you intend to submit your app to the store right away. In that case, stay with Xcode 6.4 and avoid the beta.

thank you. But i think i ned a handfull month to submit my app to the store. I alredy began with developing. i have know thre weeks expirience in developing. i don't come from this part, but i have an idea that needs an App and also i think is very interesting to learn wift and SQL Database.


but i need a lot of patience :-)


when i stil rest on 6.4, what i have to corect in that code?

i have it now :-)


I have changed back some code and know it's working with Xcode 6.4


thank you for your helpness

i have it now :-)

I have changed back some code and know it's working with Xcode 6.4

thank you for your helpness

the last thing to work know with my database is, that i have two error in this .php


I know is not swift but it have to fit with it. You know a good forum about .php and al this Database staff?


here the errors:

02. MySQLDao is an Syntax error

and

04. var is also an Syntax error!

Best regards from zurich...and many many thanks vor the help with my swift database. i'm now very hapy

<?
phpclass MySQLDao {
var $dbhost = null;
var $dbuser = null;
var $dbpass = null;
var $conn = null;
var $dbname = null;
var $result = null;
function __construct()
$this->dbhost = Conn::$dbhost;
$this->dbuser = Conn::$dbuser;
$this->dbpass = Conn::$dbpass;
$this->dbname = Conn::$dbname;
}
public function openConnection() {
$this->conn = new mysqli($this->dbhost, $this->dbuser, $this->dbpass, $this->dbname);
if (mysqli_connect_errno())
echo new Exception(“Could not establish connection with database”);
}
public function getConnection() {
return $this->conn;
}
public function closeConnection() {
if ($this->conn != null)
$this->conn->close();
}
public function getUserDetails($email)
{
$returnValue = array();
$sql = “select * from users where user_email='” . $email . “‘”;
$result = $this->conn->query($sql);
if ($result != null && (mysqli_num_rows($result) >= 1)) {
$row = $result->fetch_array(MYSQLI_ASSOC);
if (!empty($row)) {
$returnValue = $row;
}
}
return $returnValue;
}
public function getUserDetailsWithPassword($email, $userPassword)
{
$returnValue = array();
$sql = “select id,user_email from users where user_email='” . $email . “‘ and user_password='” .$userPassword . “‘”;
$result = $this->conn->query($sql);
if ($result != null && (mysqli_num_rows($result) >= 1)) {
$row = $result->fetch_array(MYSQLI_ASSOC);
if (!empty($row)) {
$returnValue = $row;
}
}
return $returnValue;
}
public function registerUser($email, $password)
{
$sql = “insert into users set user_email=?, user_password=?”;
$statement = $this->conn->prepare($sql);
if (!$statement)
throw new Exception($statement->error);
$statement->bind_param(“ss”, $email, $password);
$returnValue = $statement->execute();
return $returnValue;
}
}
?>
one error in my last row of my code
 
 
Q