D. Rao D. Rao - 8 months ago 48
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?

 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/