D. Rao D. Rao - 1 year ago 122
iOS Question

Swift: Reload alamofire request every 10 seconds

I am trying to get information from an alamofire request and I want the information to be updated every 10 seconds. In other words, I want it to refresh. So I want it to repeat the http request every 10 seconds. Does anyone know how to do this?

Answer Source
 override func viewDidLoad() {
  var timer = NSTimer.scheduledTimerWithTimeInterval(0.4, target: self,selector: "execute", userInfo: nil, repeats: true)

// method

 func execute() {
 // do logic here

more ablout NSTImer http://www.ios-blog.co.uk/tutorials/swift/swift-nstimer-tutorial-lets-create-a-counter-application/

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download