         return self.locationCoreDataModel?.items ?? []
     }
     
+    var selectedLocation: LocationDataItem? {
+        if let index = self.selectedLocationIndex {
+            return self.locations[index]
+        }
+        return nil
+    }
+    
     // MARK: -
+    
     func descriptionForError(error: NSError) -> String {
         if error.domain == kCLErrorDomain {
             return "Current location detection is not available."

        super.init()
    }
    
    var selectedLocationIndex: Int? {
        get {
            let userDefaults = NSUserDefaults.standardUserDefaults()
            let number = userDefaults.objectForKey("selectedLocationIndex") as! NSNumber?
            return number?.integerValue
        }
        set(index) {
            let number: NSNumber? = index != nil ? NSNumber(long: index!) : nil
            let userDefaults = NSUserDefaults.standardUserDefaults()
            userDefaults.setObject(number, forKey: "selectedLocationIndex")
        }
    }
    
    // MARK: - Weather
    
    func weatherForSelectedLocation(callback: (WeatherDataItem?, NSError?) -> Void) {
        if let index = self.selectedLocationIndex {
            let item = self.locations[index]
            self.weatherForLocationItem(item, callback: callback)
        } else {
            self.weatherForCurrentLocation(callback)
        }

    
    // MARK: - Stored locations management
    
    var selectedLocationIndex: Int? {
        get {
            let userDefaults = NSUserDefaults.standardUserDefaults()
            let number = userDefaults.objectForKey("selectedLocationIndex") as! NSNumber?
            return number?.integerValue
        }
        set(index) {
            let number: NSNumber? = index != nil ? NSNumber(long: index!) : nil
            let userDefaults = NSUserDefaults.standardUserDefaults()
            userDefaults.setObject(number, forKey: "selectedLocationIndex")
        }
    }
    
    func addLocationWithName(name: String, country: String, countryCode: String) {
        self.locationCoreDataModel?.newItemWithName(name, country: country, countryCode: countryCode)
    }
