         }
     }
     
+    public func addMapping(url: String, imageNamed: String) {
+        addMapping(url, entry: "asset://" + imageNamed)
+    }
+
     public func addMapping(url: String, path: String) {
         var isDir: ObjCBool = false
         if NSFileManager.defaultManager().fileExistsAtPath(path, isDirectory: &isDir) {
             let path = !isDir || path.hasSuffix("/") ? path : path + "/"
-            dispatch_async(self.queue) {
-                let mapping = (url: url, path: path)
-                if let index = self.mappings.indexOf({ $0.url == url }) {
-                    self.mappings[index] = mapping
-                } else {
-                    self.mappings.append(mapping)
-                }
+            addMapping(url, entry: path)
+        }
+    }
+    
+    private func addMapping(url: String, entry: String) {
+        dispatch_async(self.queue) {
+            let mapping = (url: url, path: entry)
+            if let index = self.mappings.indexOf({ $0.url == url }) {
+                self.mappings[index] = mapping
+            } else {
+                self.mappings.append(mapping)
             }
         }
     }

                return
            }
            
            guard let fileSize = self.getFileSize(path) else {
                receiver.onReceiveAborted(WebCacheError("WebCacheMonk.InvalidResource", url: url))
                return
            }
            
            let offset = offset ?? 0
            var length = length ?? (fileSize - offset)
            
            guard offset + length <= fileSize else {
                receiver.onReceiveAborted(WebCacheError("WebCacheMonk.InvalidRange", url: url))
                return
            }
            
            guard let input = NSFileHandle(forReadingAtPath: path) else {
                receiver.onReceiveAborted(WebCacheError("WebCacheMonk.InvalidResource", url: url))
                return
            }
            
            defer {
                input.closeFile()
            }
            
            let info = WebCacheInfo(mimeType: self.getMimeType(path))
            info.totalLength = fileSize

            if progress?.totalUnitCount < 0 {
                progress?.totalUnitCount = length
            }

            receiver.onReceiveStarted(info, offset: offset, length: length)
            
            input.seekToFileOffset(UInt64(offset))
            while length > 0 {
                let size = min(65536, length)
                let data = input.readDataOfLength(Int(size))
                receiver.onReceiveData(data)
                progress?.completedUnitCount += size
                length -= size
            }
            
            receiver.onReceiveFinished()
        }
    }

    public func check(url: String, offset: Int64?, length: Int64?, completion: (Int64?) -> Void) {
        dispatch_async(self.queue) {
            guard let path = self.getPath(url),
                      fileSize = self.getFileSize(path) else {
                completion(nil)
                return
            }
            
            let offset = offset ?? 0
            let length = length ?? (fileSize - offset)
            if offset + length <= fileSize {
                completion(fileSize)
            } else {
                completion(nil)
            }

        return nil
    }
    
    private func getAssetData(path: String) -> NSData? {
        if !path.hasPrefix("asset://") {
            return nil
        }
        
        let path = path.substringFromIndex(path.startIndex.advancedBy(8))
        guard let r = path.rangeOfString(".", options: .BackwardsSearch) else {
            return nil
        }
        
        let name = path.substringToIndex(r.startIndex)
        guard let image = UIImage(named: name) else {
            return nil
        }
        
        let ext = path.substringFromIndex(r.endIndex.advancedBy(1))
        switch ext {
        case "jpg", "jpeg":
            return UIImageJPEGRepresentation(image, 1.0)
        
        case "png":
            return UIImagePNGRepresentation(image)
        
        default:
            return nil
        }
    }
    
    private func getFileSize(path: String) -> Int64? {
        guard let attributes = try? NSFileManager.defaultManager().attributesOfItemAtPath(path) else {
            return nil
        }
        if attributes[NSFileType] as? String == NSFileTypeDirectory {
            return nil
        } else {
            return (attributes[NSFileSize] as? NSNumber)?.longLongValue
        }
    }
    
