Saturday, 15 August 2015

ios - Handle a JSON Response with Alamofire in Swift -



ios - Handle a JSON Response with Alamofire in Swift -

i have problem want handle json response alamofire in swift found reply on stackoverflow unfortunately post few days older. question how can receive info alamofire on first button press (without swiftyjson). hope help me.

this link found on stackoverflow.

handle json response alamofire in swift

this little example.

this json returns if fails json_file.json

{ "transaction":"error" }

this json returns if success json_file.json

{ "transaction":"success" }

this code , must add together own url homecoming of json responses. (example only)

alamofire.request(.get, "http://myjsonexamplewebsite.com/json_file.json", parameters:nil) .responsejson { (_, _, json, _) in //println(json) var response = json nsdictionary var transaction = response.objectforkey("transaction") string if transaction == "success" { nslog("json response successfull") } else { nslog("json response had error") } }

ios iphone json swift alamofire

No comments:

Post a Comment