title: How to call a function from an extension in Swift
body: <p>I am using the INSPhotoGallery framework(<a href="https://github.com/inspace-io/INSPhotoGallery" rel="nofollow">https://github.com/inspace-io/INSPhotoGallery</a>), which is a photo gallery framework. I want to call a specific method on start, effectively making a preview on start rather than the overview / table view. I'd like to display the first cell preview image (which is displayed when you click on it).</p>
  
  <pre><code>//
  //  ViewController.swift
  //  INSPhotoGallery
  //
  //  Created by Michal Zaborowski on 04.04.2016.
  //  Copyright © 2016 Inspace Labs Sp z o. o. Spółka Komandytowa. All rights reserved.
  //
  
  import UIKit
  import INSPhotoGalleryFramework
  
  class ViewController: UIViewController {
  
      @IBOutlet weak var collectionView: UICollectionView!
      var useCustomOverlay = false
  
  
  
      lazy var photos: [INSPhotoViewable] = {
          return [
              INSPhoto(imageURL: NSURL(string: "http://i.imgur.com/JXY2d4A.jpg"), thumbnailImageURL: NSURL(string: "http://i.imgur.com/JXY2d4A.jpg")),
              INSPhoto(imageURL: NSURL(string: "http://i.imgur.com/NC4bqLB.jpg"), thumbnailImageURL: NSURL(string: "http://i.imgur.com/NC4bqLB.jpg")),
              INSPhoto(imageURL: NSURL(string: "http://i.imgur.com/jBbQXNz.jpg"), thumbnailImageURL: NSURL(string: "http://i.imgur.com/jBbQXNz.jpg")),
              INSPhoto(imageURL: NSURL(string: "http://i.imgur.com/WCXkdwW.jpg"), thumbnailImageURL: NSURL(string: "http://i.imgur.com/WCXkdwW.jpg")),
              INSPhoto(imageURL: NSURL(string: "http://i.imgur.com/p7ujK0t.jpg"), thumbnailImageURL: NSURL(string: "http://i.imgur.com/p7ujK0t.jpg")),
              INSPhoto(imageURL: NSURL(string: "http://i.imgur.com/Ak4qwsS.jpg"), thumbnailImageURL: NSURL(string: "http://i.imgur.com/Ak4qwsS.jpg")),
              INSPhoto(imageURL: NSURL(string: "http://i.imgur.com/w2JJtDf.jpg"), thumbnailImageURL: NSURL(string: "http://i.imgur.com/w2JJtDf.jpg")),
              INSPhoto(imageURL: NSURL(string: "http://i.imgur.com/HCCSco3.jpg"), thumbnailImageURL: NSURL(string: "http://i.imgur.com/HCCSco3.jpg")),
              INSPhoto(imageURL: NSURL(string: "http://i.imgur.com/Za6Ialf.jpg"), thumbnailImageURL: NSURL(string: "http://i.imgur.com/Za6Ialf.jpg")),
  
              INSPhoto(imageURL: NSURL(string: "http://i.imgur.com/Pqc6k4v.jpg"), thumbnailImageURL: NSURL(string: "http://i.imgur.com/Pqc6k4v.jpg")),
              INSPhoto(imageURL: NSURL(string: "http://i.imgur.com/D8BBMd4.jpg"), thumbnailImageURL: NSURL(string: "http://i.imgur.com/D8BBMd4.jpg")),
              INSPhoto(imageURL: NSURL(string: "http://i.imgur.com/bggxrss.jpg"), thumbnailImageURL: NSURL(string: "http://i.imgur.com/bggxrss.jpg")),
              INSPhoto(imageURL: NSURL(string: "http://i.imgur.com/w1Lnl2c.jpg"), thumbnailImageURL: NSURL(string: "http://i.imgur.com/w1Lnl2c.jpg")),
              INSPhoto(imageURL: NSURL(string: "http://i.imgur.com/qoA0qA9.jpg"), thumbnailImageURL: NSURL(string: "http://i.imgur.com/qoA0qA9.jpg")),
              INSPhoto(imageURL: NSURL(string: "http://i.imgur.com/DkCEfkw.jpg"), thumbnailImageURL: NSURL(string: "http://i.imgur.com/DkCEfkw.jpg")),
              INSPhoto(imageURL: NSURL(string: "http://i.imgur.com/U4ihOo6.jpg"), thumbnailImageURL: NSURL(string: "http://i.imgur.com/U4ihOo6.jpg")),
              INSPhoto(imageURL: NSURL(string: "http://i.imgur.com/QvLBs7A.jpg"), thumbnailImageURL: NSURL(string: "http://i.imgur.com/QvLBs7A.jpg")),
              INSPhoto(imageURL: NSURL(string: "http://i.imgur.com/ZytdIk1.jpg"), thumbnailImageURL: NSURL(string: "http://i.imgur.com/ZytdIk1.jpg")),
  
          ]
      }()
  
      override func viewDidLoad() {
          super.viewDidLoad()
          collectionView.delegate = self
          collectionView.dataSource = self
  
          for photo in photos {
              if let photo = photo as? INSPhoto {
                  photo.attributedTitle = NSAttributedString(string: "Note: Click top right to download wallpaper, \nscroll left or right to browse", attributes: [NSForegroundColorAttributeName: UIColor.whiteColor()])
              }
          }
  
  
      }
  }
  
  extension ViewController: UICollectionViewDataSource, UICollectionViewDelegateFlowLayout {
      func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -&gt; UICollectionViewCell {
          let cell = collectionView.dequeueReusableCellWithReuseIdentifier("ExampleCollectionViewCell", forIndexPath: indexPath) as! ExampleCollectionViewCell
          cell.populateWithPhoto(photos[indexPath.row])
  
  
  
          return cell
      }
      func collectionView(collectionView: UICollectionView, numberOfItemsInSection section: Int) -&gt; Int {
          return photos.count
      }
  
      func collectionView(collectionView: UICollectionView, didSelectItemAtIndexPath indexPath: NSIndexPath) {
          print(indexPath)
          let cell = collectionView.cellForItemAtIndexPath(indexPath) as! ExampleCollectionViewCell
          let currentPhoto = photos[indexPath.row]
          let galleryPreview = INSPhotosViewController(photos: photos, initialPhoto: currentPhoto, referenceView: cell)
          if useCustomOverlay {
              galleryPreview.overlayView = CustomOverlayView(frame: CGRect.zero)
          }
  
          galleryPreview.referenceViewForPhotoWhenDismissingHandler = { [weak self] photo in
              if let index = self?.photos.indexOf({$0 === photo}) {
                  let indexPath = NSIndexPath(forItem: index, inSection: 0)
                  return collectionView.cellForItemAtIndexPath(indexPath) as? ExampleCollectionViewCell
              }
              return nil
          }
  </code></pre>
  
  <p>this one:</p>
  
  <pre><code>presentViewController(galleryPreview, animated: true, completion: nil)
          }
      }
  </code></pre>