   }
 }
 
-class PIImageCache {
+public class PIImageCache {
   
-  init() {
+  public init() {
     maxCount = 10
     maxByteSize = 3 * 1024 * 1024 //3MB
   }
   
-  init(maxCount: Int, maxByteSize: Int) {
+  public init(maxCount: Int, maxByteSize: Int) {
     self.maxCount = maxCount
     self.maxByteSize = maxByteSize
   }
   
-  class var shared: PIImageCache {
+  public class var shared: PIImageCache {
     struct Static {
       static let instance: PIImageCache = PIImageCache()
     }
     return Static.instance
   }
   
-  struct cacheImage {
+  private struct cacheImage {
     let image     :UIImage
     var timeStamp :Double
     let url       :NSURL
   }
   
-  var now: Double {
+  private var now: Double {
     get {
       return NSDate().timeIntervalSince1970
     }
   }
   
-  let maxCount : Int
-  let maxByteSize  : Int
+  private let maxCount : Int
+  private let maxByteSize  : Int
   
-  var cache : [cacheImage] = []
+  private var cache : [cacheImage] = []
   
-  func cacheRead(url: NSURL) -> UIImage? {
+  private func cacheRead(url: NSURL) -> UIImage? {
     for var i=0; i<cache.count; i++ {
       if url == cache[i].url {
         cache[i].timeStamp = now

    }
  }
  
  func download(url: NSURL) -> (UIImage, byteSize: Int)? {
    var err: NSError?
    var maybeImageData = NSData(contentsOfURL: url, options:.UncachedRead, error: &err)
    if let e = err { println(e) }


import UIKit

public extension NSURL {
  public func getImageWithCache(cache: PIImageCache) -> UIImage? {
    return cache.get(self)
  }
}

public extension UIImageView {
  public func imageOfURL(url: NSURL, cache: PIImageCache) {
    cache.get(url) {
      [weak self] img in
      self?.image = img
