     //private var items = [[String:AnyObject]]()
     private var url:NSURL?
     private weak var delegate:SwipeDocumentViewerDelegate?
-
+    private var prefetching = true
+
+    // Returns the list of URLs of required resouces for this element (including children)
+    private lazy var resourceURLs:[NSURL:String] = {
+        var urls = [NSURL:String]()
+        for section in self.sections {
+            guard let items = section["items"] as? [[String:AnyObject]] else {
+                continue
+            }
+            for item in items {
+                if let icon = item["icon"] as? String,
+                       url = NSURL.url(icon, baseURL: self.url) {
+                    urls[url] = "" // no prefix
+                }
+            }
+        }
+        return urls
+    }()
+
+    lazy var prefetcher:SwipePrefetcher = {
+        return SwipePrefetcher(urls:self.resourceURLs)
+    }()
+        
     // <SwipeDocumentViewer> method
     func loadDocument(document:[String:AnyObject], size:CGSize, url:NSURL?, state:[String:AnyObject]?) throws {
         self.document = document


        // Uncomment the following line to display an Edit button in the navigation bar for this view controller.
        // self.navigationItem.rightBarButtonItem = self.editButtonItem()
    }

    override func didReceiveMemoryWarning() {

        }
        if let icon = item["icon"] as? String,
               url = NSURL.url(icon, baseURL: self.url),
               urlLocal = self.prefetcher.map(url),
               path = urlLocal.path,
               image = UIImage(contentsOfFile: path) {
            cell.imageView?.image = image
        }
