         // Create the coordinator and store
         var coordinator: NSPersistentStoreCoordinator? = NSPersistentStoreCoordinator(managedObjectModel: self.managedObjectModel)
         let url = self.applicationCachesDirectory.URLByAppendingPathComponent("HYLNetworkCaching.sqlite")
-        var error: NSError? = nil
         var failureReason = "There was an error creating or loading the application's saved data."
         do {
             try coordinator!.addPersistentStoreWithType(NSSQLiteStoreType, configuration: nil, URL: url, options: nil)
-        } catch var error1 as NSError {
-            error = error1
+        } catch var error as NSError {
             coordinator = nil
             // Report any error we got.
             var dict = [String: AnyObject]()

    }
    
    
    // MARK: - internal methods
    func fetchDataForModelName(modelName:String, success:((data:AnyObject?)->Void)?, failure:((error:NSError)->Void)?){
        /* fetch cached data */
        if let cachedData: AnyObject? = fetchDataFromCoredataForModelName(modelName), successBlock = success {
            successBlock(data: cachedData)
        }
        
        if self.delegate == nil {
            return
        }
        self.delegate!.fetchDataFromNetworkForModelName(modelName, success: { (data) -> Void in
            self.updateCacheForModelName(modelName, data: data)
                if let successBlock = success {
                    successBlock(data: data)
                }
            }, failure:{(error)->Void in
                if let failureBlock = failure {
                    failureBlock(error: error)
                }
        })
    }
    

            error = NSError(domain: "YOUR_ERROR_DOMAIN", code: 9999, userInfo: dict)
            // Replace this with code to handle the error appropriately.
            // abort() causes the application to generate a crash log and terminate. You should not use this function in a shipping application, although it may be useful during development.
            NSLog("Unresolved error \(error), \(error.userInfo)")
            abort()
        } catch {
            fatalError()
