sendAsynchronousRequest was deprecated in iOS 9, How to alter code to fix

Use NSURLSession instead like below,

For Objective-C

NSURLSession *session = [NSURLSession sharedSession];
[[session dataTaskWithURL:[NSURL URLWithString:"YOUR URL"]
          completionHandler:^(NSData *data,
                              NSURLResponse *response,
                              NSError *error) {
            // handle response

  }] resume];

For Swift,

    var request = NSMutableURLRequest(URL: NSURL(string: "YOUR URL")!)
    var session = NSURLSession.sharedSession()
    request.HTTPMethod = "POST"

    var params = ["username":"username", "password":"password"] as Dictionary<String, String>

    request.HTTPBody = try? NSJSONSerialization.dataWithJSONObject(params, options: [])

    request.addValue("application/json", forHTTPHeaderField: "Content-Type")
    request.addValue("application/json", forHTTPHeaderField: "Accept")

    var task = session.dataTaskWithRequest(request, completionHandler: {data, response, error -> Void in
        print("Response: \(response)")})

    task.resume()

For asynchronously query, from Apple docs

Like most networking APIs, the NSURLSession API is highly
asynchronous. It returns data in one of two ways, depending on the
methods you call:

To a completion handler block that returns data to your app when a
transfer finishes successfully or with an error.

By calling methods on your custom delegate as the data is received.

By calling methods on your custom delegate when download to a file is
complete.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)