daily pastebin goal
67%
SHARE
TWEET

Untitled

a guest Mar 17th, 2018 70 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. func getUserLogin(username:String,password:String, onSuccess:@escaping(JSON)-> Void, onFailure: @escaping(Error)->Void){
  2.         let url:String = baseURL+APIManager.getUserLogin
  3.         let request: NSMutableURLRequest = NSMutableURLRequest(url: NSURL(string: url)! as URL)
  4.         request.httpMethod="POST"
  5.         let postString = "username="+username+"&password="+password
  6.         request.httpBody = postString.data(using: .utf8)
  7.         let session = URLSession.shared
  8.  
  9.         let task = session.dataTask(with: request as URLRequest,completionHandler:{data,response,error->Void in if(error != nil){onFailure(error!)
  10.  
  11.         }else {
  12.             let result = JSON(data: data!)
  13.             onSuccess(result)
  14.             }
  15.  
  16.         })
  17.         task.resume()
  18.  
  19.     }
  20.    
  21. let result = JSON(data: data!)
  22.         onSuccess(result)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top