Last active
August 29, 2015 14:12
-
-
Save hardez/a7a68e986b2626055fb5 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func postArrayToUrl(urlToRequest: String, params: NSMutableDictionary) -> AnyObject { | |
var url: NSURL = NSURL(string: urlToRequest)! | |
var request = NSMutableURLRequest(URL: url) | |
var response: NSURLResponse? | |
var error: AutoreleasingUnsafeMutablePointer <NSError?> = nil | |
request.HTTPMethod = "POST" | |
request.HTTPBody = NSJSONSerialization.dataWithJSONObject(params, options: nil, error: error) | |
request.setValue("application/json", forHTTPHeaderField: "Content-Type") | |
var test = NSURLConnection.sendSynchronousRequest(request, returningResponse: &response, error: error) | |
var resp:AnyObject = NSJSONSerialization.JSONObjectWithData(test!, options: NSJSONReadingOptions.MutableContainers, error: error)! as AnyObject | |
return resp | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment