title: QuickLook class not working
body: <p>I have this class which works fine</p>
  
  <p>import UIKit
  import QuickLook</p>
  
  <pre><code>class ViewController: UITableViewController, QLPreviewControllerDataSource {
  
      var urlList : [NSURL]? = {
          if let fileURL1 = NSBundle.mainBundle().URLForResource("Essay", withExtension:"txt"),
              let fileURL2 = NSBundle.mainBundle().URLForResource("Image", withExtension:"jpg"),
              let fileURL3 = NSBundle.mainBundle().URLForResource("Letter", withExtension:"docx"),
              let fileURL4 = NSBundle.mainBundle().URLForResource("Newsletter", withExtension:"pages"),
              let fileURL5 = NSBundle.mainBundle().URLForResource("Presentation", withExtension:"key"),
              let fileURL6 = NSBundle.mainBundle().URLForResource("VisualReport", withExtension:"pdf"),
              let fileURL7 = NSBundle.mainBundle().URLForResource("aaa", withExtension:"x")
          {
                  return [ fileURL1 , fileURL2, fileURL3, fileURL4, fileURL5, fileURL6, fileURL7 ]
          }
          return nil
      }()
  
      override func viewDidLoad() {
          super.viewDidLoad()
      }
  
  
      override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -&gt; Int {
          if let list = urlList {
              return list.count 
          }
          return 0
      }
  
      override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -&gt; UITableViewCell {
          let cell = tableView.dequeueReusableCellWithIdentifier("default", forIndexPath: indexPath) 
          if let list = urlList, let fileName = list[indexPath.row].lastPathComponent {
              cell.textLabel?.text = fileName
          }
          return cell
      }
  
      override func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
          let previewQL = QLPreviewController() 
          previewQL.dataSource = self as QLPreviewControllerDataSource 
          previewQL.currentPreviewItemIndex = indexPath.row 
          showViewController(previewQL, sender: nil) 
      }
  
      func numberOfPreviewItemsInPreviewController(controller: QLPreviewController) -&gt; Int {
          if let list = urlList {
              return list.count
          }
          return 0
      }
  
      func previewController(controller: QLPreviewController, previewItemAtIndex index: Int) -&gt; QLPreviewItem {
          var fileURL : NSURL?
          if let list = urlList, let filePath = list[index].lastPathComponent {
              fileURL = NSBundle.mainBundle().URLForResource(filePath, withExtension:nil)
          }
  
          print(fileURL!)
          return fileURL!
      }
  }
  </code></pre>
  
  <p>but when I change the Quick look to be another class as follows it stops working?</p>
  
  <pre><code>import UIKit
  import QuickLook
  
  class ViewController: UITableViewController {
  
      var urlList : [NSURL]? = {
          if let fileURL1 = NSBundle.mainBundle().URLForResource("Essay", withExtension:"txt"),
              let fileURL2 = NSBundle.mainBundle().URLForResource("Image", withExtension:"jpg"),
              let fileURL3 = NSBundle.mainBundle().URLForResource("Letter", withExtension:"docx"),
              let fileURL4 = NSBundle.mainBundle().URLForResource("Newsletter", withExtension:"pages"),
              let fileURL5 = NSBundle.mainBundle().URLForResource("Presentation", withExtension:"key"),
              let fileURL6 = NSBundle.mainBundle().URLForResource("VisualReport", withExtension:"pdf"),
              let fileURL7 = NSBundle.mainBundle().URLForResource("aaa", withExtension:"x")
          {
                  return [ fileURL1 , fileURL2, fileURL3, fileURL4, fileURL5, fileURL6, fileURL7 ]
          }
          return nil
      }()
  
      override func viewDidLoad() {
          super.viewDidLoad()
      }
  
  
      override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -&gt; Int {
          if let list = urlList {
              return list.count // 2
          }
          return 0
      }
  
      override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -&gt; UITableViewCell {
          let cell = tableView.dequeueReusableCellWithIdentifier("default", forIndexPath: indexPath) 
          if let list = urlList, let fileName = list[indexPath.row].lastPathComponent {
              cell.textLabel?.text = fileName // 3
          }
          return cell
      }
  
      override func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
          _  = PreviewController(controller: self, documentURL: urlList![indexPath.row])
      }
  }
  </code></pre>
  
  <p>and</p>
  
  <pre><code>import UIKit
  import QuickLook
  
  class PreviewController: NSObject, QLPreviewControllerDataSource {
  
      var documentURL: NSURL
  
      init(controller: ViewController, documentURL: NSURL) {
          self.documentURL = documentURL
  
          super.init()
  
          let previewQL = QLPreviewController()
          previewQL.dataSource = self as QLPreviewControllerDataSource
          previewQL.currentPreviewItemIndex = 0
          controller.showViewController(previewQL, sender: nil)
      }
  
      func numberOfPreviewItemsInPreviewController(controller: QLPreviewController) -&gt; Int {
          return 1
      }
  
      func previewController(controller: QLPreviewController, previewItemAtIndex index: Int) -&gt; QLPreviewItem {
          return documentURL
      }
  }
  </code></pre>
  
  <p>Any ideas why the refactored class PreviewController doesn't work?</p>