ios - how to get a new JSON response without closing and reloading the app -


i started building app uses rest api, testing json response in console.

i have 2 uitextfields jobkeyword & location user enter, json shows in console upon clicking "search" button.

but can't new search without closing re-running app. how update field , new response without leaving app? i'm new in ios development. here viewcontroller.swift:

import uikit import alamofire class viewcontroller: uiviewcontroller {  let headers = ["host":"data.usajobs.gov",                "user-agent":"dezbill@icloud.com",                "authorization-key":"********************"              ]  @iboutlet weak var jobkeywordtxt: uitextfield!  @iboutlet var locationtxt: uitextfield! @iboutlet weak var locationstate: uitextfield!  override func viewdidload() {     super.viewdidload()  }  override func viewdidappear(animated: bool) {     super.viewdidappear(true)  }   @ibaction func searchbtn(sender: uibutton) {      let jobkeyword = jobkeywordtxt.text     let location = locationtxt.text      alamofire.request(.get, "https://data.usajobs.gov/api/search", parameters:["locationname":location!,"positiontitle":jobkeyword!]).responsejson { response in           debugprint(response)           print(self.locationtxt.text)     } } 

}

screenshot of project

can try following code , see whether works.

alamofire.request(.get, "https://data.usajobs.gov/api/search", parameters:["locationname":location!,"positiontitle":jobkeyword!])      .response { request, response, data, error in          print(request)          print(response)          print(data)          print(error)       } 

if still doesn't work, try installing charles(http debugger) , route network traffic via charles. you'll able @ least identify whether request sent each time.


Comments

Popular posts from this blog

javascript - jQuery: Add class depending on URL in the best way -

caching - How to check if a url path exists in the service worker cache -

Redirect to a HTTPS version using .htaccess -