Cannot invoke 'jsonObject' with an argument list of type '(with: NSData, options: JSONSerialization.ReadingOptions, error: inout NSError?)
<p>I'm a new beginner developer for iOS, still learning from youtube or read some ebooks about swift, etc. </p>

<p>Actually I following this tutorial on youtube <a href="https://www.youtube.com/watch?v=v9bsZvHuQYI" rel="nofollow noreferrer">iOS Login and Signup Screen Tutorial</a> about how to create iOS login and signup with JSON data, but I think the code it didn't work well in swift 3 with xcode 8. I've some issues / errors, and I can't solve the problem at this moment, I've already google it, but I did'nt got some clue how to resolve this.</p>

<p>Here is the screenshot in my LoginVC.swift file</p>

<p><a href="https://i.stack.imgur.com/yh1ee.jpg" rel="nofollow noreferrer">Screenshot of error on my LoginVC.swift</a></p>

<p>and here's the all code in LoginVC.swift</p>

<pre><code>import UIKit

class LoginVC: UIViewController {

    @IBOutlet weak var txtUsername: UITextField!
    @IBOutlet weak var txtPassword: UITextField!


    override func viewDidLoad() {
        super.viewDidLoad()

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

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }

    @IBAction func btnLoginTapped(_ sender: UIButton) {
        // let userName = txtUsername.text;
        // let userPassword = txtPassword.text;

        let username = txtUsername.text
        let password = txtPassword.text

        if ( username!.isEqual("") || password!.isEqual("") ) {

            var alertView:UIAlertView = UIAlertView()
            alertView.title = "Sign in Failed!"
            alertView.message = "Please enter Username and Password"
            alertView.delegate = self
            alertView.addButton(withTitle: "OK")
            alertView.show()
        } else {

            var post:NSString = "username=\(username)&amp;password=\(password)" as NSString

            NSLog("PostData: %@",post);

            var url:NSURL = NSURL(string:"http://192.168.1.17/userAPI/api/users")!

            var postData:NSData = post.data(using: String.Encoding.ascii.rawValue)! as NSData

            var postLength:NSString = String( postData.length ) as NSString

            var request:NSMutableURLRequest = NSMutableURLRequest(url: url as URL)
            request.httpMethod = "POST"
            request.httpBody = postData as Data
            request.setValue(postLength as String, forHTTPHeaderField: "Content-Length")
            request.setValue("application/x-www-form-urlencoded", forHTTPHeaderField: "Content-Type")
            request.setValue("application/json", forHTTPHeaderField: "Accept")


            var reponseError: NSError?
            var response: URLResponse?

            var urlData: NSData? = NSURLConnection.sendSynchronousRequest(request, returningResponse:&amp;response, error: &amp;reponseError)

            if ( urlData != nil ) {
                let res = response as! HTTPURLResponse!;
                // let dict: [String: Any] = ["key": value]
                NSLog("Response code: %ld", res?.statusCode ?? &lt;#default value#&gt;);

                if ((res?.statusCode)! &gt;= 200 &amp;&amp; (res?.statusCode)! &lt; 300) {
                    var responseData:NSString  = NSString(data:urlData! as Data, encoding:String.Encoding.utf8.rawValue)!

                    NSLog("Response ==&gt; %@", responseData);

                    var error: NSError?

                    let jsonData:NSDictionary = JSONSerialization.jsonObject(with: urlData!, options: JSONSerialization.ReadingOptions.mutableContainers, error: &amp;error) as! NSDictionary

                    // let jsonData:NSDictionary = JSONSerialization.JSONObjectWithData(urlData!, options:JSONSerialization.ReadingOptions.MutableContainers , error: &amp;error) as! NSDictionary

                    let success:NSInteger = jsonData.value(forKey: "success") as! NSInteger

                    //[jsonData[@"success"] integerValue];

                    NSLog("Success: %ld", success);

                    if(success == 1) {
                        NSLog("Login SUCCESS");

                        var prefs:UserDefaults = UserDefaults.standard
                        prefs.set(username, forKey: "USERNAME")
                        prefs.set(1, forKey: "ISLOGGEDIN")
                        prefs.synchronize()

                        self.dismiss(animated: true, completion: nil)
                    } else {
                        var error_msg:NSString

                        if jsonData["error_message"] as? NSString != nil {
                            error_msg = jsonData["error_message"] as! NSString
                        } else {
                            error_msg = "Unknown Error"
                        }
                        var alertView:UIAlertView = UIAlertView()
                        alertView.title = "Sign in Failed!"
                        alertView.message = error_msg as String
                        alertView.delegate = self
                        alertView.addButton(withTitle: "OK")
                        alertView.show()

                    }

                } else {
                    var alertView:UIAlertView = UIAlertView()
                    alertView.title = "Sign in Failed!"
                    alertView.message = "Connection Failed"
                    alertView.delegate = self
                    alertView.addButton(withTitle: "OK")
                    alertView.show()
                }
            } else {
                var alertView:UIAlertView = UIAlertView()
                alertView.title = "Sign in Failed!"
                alertView.message = "Connection Failure"
                if let error = reponseError {
                    alertView.message = (error.localizedDescription)
                }
                alertView.delegate = self
                alertView.addButton(withTitle: "OK")
                alertView.show()
            }
        }


    }

    func textFieldShouldReturn(textField: UITextField) -&gt; Bool
    {   //delegate method
        textField.resignFirstResponder()
        return true
    }

} 
</code></pre>

<p>The error's actually on these lines:</p>

<pre><code>var urlData: NSData? = NSURLConnection.sendSynchronousRequest(request, returningResponse:&amp;response, error: &amp;reponseError)

NSLog("Response code: %ld", res?.statusCode ?? &lt;#default value#&gt;);

let jsonData:NSDictionary = JSONSerialization.jsonObject(with: urlData!, options: JSONSerialization.ReadingOptions.mutableContainers, error: &amp;error) as! NSDictionary
</code></pre>

<p>I little bit stuck and confuse how to solve this.</p>

<p>Is there someone here to help fix this? I really appreciate it. Or could be someone tell me how to learn and create login screen using API in Swift3? </p>

<p>Thank you for helping me, I wish something good happens to you all today!</p>