title: Pagination with UICollectionView working with API
body: <p>I have a working application where I am using <code>Alamofire</code> and <code>SwiftyJSON</code> to fetch images from flicr API. Now, I want to include pagination in the returned images. I am returning 5 images when the application launches and this number can increase. I want to achieve this with the <code>UICollectionView</code>. </p>
  
  <p>My codes are written below. Any help would be appreciated. 100 items are being returned on every page. </p>
  
  <p><strong>Services</strong></p>
  
  <pre><code>func setData(json: JSON) -&gt; Void {
  
          if let photos = json["photos"]["photo"].array {
              for item in photos {
  
                  let photoID = item["id"].stringValue
                  let farm = item["farm"].stringValue
                  let server = item["server"].stringValue
                  let secret = item["secret"].stringValue
                  let title = item["title"].stringValue
  
                  let imageString = "https://farm\(farm).staticflickr.com/\(server)/\(photoID)_\(secret)_b.jpg/"
                  //could use _n.jpg too
  
                  let flickrPhoto = FlickrPhotoModel(id: photoID, farm: farm, server: server, secret: secret, flickerImg: imageString, title: title)
                  flickerPhotos.append(flickrPhoto)
              }
          }
  
      }
  </code></pre>
  
  <p><strong>CONTROLLER</strong></p>
  
  <pre><code>class MainVC: UIViewController {
  
       @IBOutlet weak var collectionView: UICollectionView!
  
      override func viewDidLoad() {
          super.viewDidLoad()
  
          collectionView.delegate = self
          collectionView.dataSource = self
  
  
          ServiceProvider.instance.getPhotos { (success) in
              if success {
                  self.collectionView.reloadData()
              }
          }
      }
  
  }
  
  
  extension MainVC: UICollectionViewDelegate, UICollectionViewDataSource, UICollectionViewDelegateFlowLayout {
  
      func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -&gt; UICollectionViewCell {
  
          if let cell = collectionView.dequeueReusableCell(withReuseIdentifier: PHOTO_CELL, for: indexPath) as? MainCell {
  
               let flickerPhoto = ServiceProvider.instance.flickerPhotos[indexPath.row]
  
              cell.configueCell(flickerPhotoModel: flickerPhoto, index: indexPath.item)
              return cell
          }
          return MainCell()
      }
  
      func numberOfSections(in collectionView: UICollectionView) -&gt; Int {
          return 1
      }
  
      func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -&gt; Int {
          return ServiceProvider.instance.flickerPhotos.count
      }
  }
  </code></pre>
  
  <p>Further codes would be supplied on request.</p>