title: A decent way to structure Alamofire requests in swift app
body: <p>I'm a iOS noobie and have a method which loads some json from a server using Alamofire and the parses the JSON. My code looks a little like something below with the retry every 5 seconds.</p>
  
  <pre><code>func loadData() {
      let end_point = "likes/" + String(UserInfo.sharedData.userId)
      let url = MyConfig.sharedData.url + end_point
      Alamofire.request(.GET, url).responseJSON{ (request, response, json, error) in
          if (error == nil) {
              println(request, response, error)
              var products = ParseProduct(json)
              for product in products {
                  self.likes.append(product)
              }
              self.collectionView.reloadData()
          } else {
              println("failed will try again in 5 seconds")
              let delayInSeconds = 5.0
              let delay = dispatch_time(DISPATCH_TIME_NOW, Int64(delayInSeconds * Double(NSEC_PER_SEC)))
                  dispatch_after(delay, dispatch_get_main_queue()) {
                      self.loadData()
              }
          }
  
      }
  }
  </code></pre>
  
  <p>This seems tedious repeating this retry for every Alamofire request I have. What is a good way to structure this code for multiple requests for multiple URLS.</p>