let url string = "https://myURL"
func task(_ urlstring: String,json: AnyObject, ComplitionHandler: @escaping taskCompletionHandler  )
{
    do
    {
        let jsonData = try JSONSerialization.data(withJSONObject: json, options: .prettyPrinted)
        let url = URL(string: urlstring)
        var request = URLRequest(url: url!)
        request.httpMethod = "POST"
        request.httpBody = jsonData
        request.addValue("application/json", forHTTPHeaderField: "Content-Type")
        let task = URLSession.shared.dataTask(with: request, completionHandler: {(data,response,error) in
                if(error != nil)
                {
                    print(error)
                    ComplitionHandler(nil, nil )
                    return
                }
                ComplitionHandler(data!, response!)
        })            
        task.resume()
    }
    catch
    {
        print("error")
    }
}
I have done some Changes in .plist by adding 
(App Transport Security ,Allow Arbitrary Loads=YES,Allow Arbitrary Loads in Web Content=YES).
But Still getting below error:
NSLocalizedDescription=An SSL error has occurred and a secure connection to the server cannot be made., NSErrorFailingURLKey=https://myurl, NSErrorFailingURLStringKey=https://myurl, NSErrorClientCertificateStateKey=0
 
     
    