I have already tried 1000 and 1 thing and still could not find a way to call my web service and get the results you want.
Can someone tell me the best way to connect to my web service and call my methods in swift2 with xcode 7?
I have already tried 1000 and 1 thing and still could not find a way to call my web service and get the results you want.
Can someone tell me the best way to connect to my web service and call my methods in swift2 with xcode 7?
Using the Alamofire library I made the request as follows:
let URL = NSURL(string: "https://****.*****.com/*****.svc/rest/GetByID")!
let mutableURLRequest = NSMutableURLRequest(URL: URL)
mutableURLRequest.HTTPMethod = "POST"
let parameters = ["ID": "23"]
do {
mutableURLRequest.HTTPBody = try NSJSONSerialization.dataWithJSONObject(parameters, options: NSJSONWritingOptions())
} catch {
}
mutableURLRequest.setValue("application/json", forHTTPHeaderField: "Content-Type")
Alamofire.request(mutableURLRequest)
.responseJSON{
response in
if let JSON = response.result.value{
let dataSelected = [JSON.valueForKey("Price")!] //Quando vem apenas um objecto
print("RESULTADO \(dataSelected)")
}
}