Commit f0f001bc by Demid Merzlyakov

Update manager.

parent 4758da0a
......@@ -12,6 +12,7 @@
870880212578ED190076BFB1 /* WdtDaySummary.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8708801E2578ED190076BFB1 /* WdtDaySummary.swift */; };
870880222578ED190076BFB1 /* WdtHourSummary.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8708801F2578ED190076BFB1 /* WdtHourSummary.swift */; };
870880232578ED190076BFB1 /* WdtCondition.swift in Sources */ = {isa = PBXBuildFile; fileRef = 870880202578ED190076BFB1 /* WdtCondition.swift */; };
870880262578F7030076BFB1 /* WeatherUpdateManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 870880252578F7030076BFB1 /* WeatherUpdateManager.swift */; };
CD1237C3255D5C5900C98139 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = CD1237C2255D5C5900C98139 /* AppDelegate.swift */; };
CD1237C7255D5C5900C98139 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = CD1237C6255D5C5900C98139 /* ViewController.swift */; };
CD1237CC255D5C5C00C98139 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = CD1237CB255D5C5C00C98139 /* Assets.xcassets */; };
......@@ -40,6 +41,7 @@
8708801E2578ED190076BFB1 /* WdtDaySummary.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = WdtDaySummary.swift; sourceTree = "<group>"; };
8708801F2578ED190076BFB1 /* WdtHourSummary.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = WdtHourSummary.swift; sourceTree = "<group>"; };
870880202578ED190076BFB1 /* WdtCondition.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = WdtCondition.swift; sourceTree = "<group>"; };
870880252578F7030076BFB1 /* WeatherUpdateManager.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = WeatherUpdateManager.swift; sourceTree = "<group>"; };
C8C576F6184B547435CFF0F3 /* Pods-1Weather.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-1Weather.debug.xcconfig"; path = "Target Support Files/Pods-1Weather/Pods-1Weather.debug.xcconfig"; sourceTree = "<group>"; };
CD1237BF255D5C5900C98139 /* 1Weather.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = 1Weather.app; sourceTree = BUILT_PRODUCTS_DIR; };
CD1237C2255D5C5900C98139 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
......@@ -176,6 +178,7 @@
CDA69B2E2575008700CB6409 /* Models */ = {
isa = PBXGroup;
children = (
870880252578F7030076BFB1 /* WeatherUpdateManager.swift */,
CDA69B2F257500E200CB6409 /* GeoNamesPlace.swift */,
8708801B2578DDD50076BFB1 /* WdtLocation.swift */,
870880202578ED190076BFB1 /* WdtCondition.swift */,
......@@ -370,6 +373,7 @@
CD1237F4255D889F00C98139 /* GradientView.swift in Sources */,
CD1237C3255D5C5900C98139 /* AppDelegate.swift in Sources */,
CD6B304325726AD1004B34B3 /* DefaultTheme.swift in Sources */,
870880262578F7030076BFB1 /* WeatherUpdateManager.swift in Sources */,
CD6B3036257262C2004B34B3 /* UIColor+Highlight.swift in Sources */,
CDA69B3325750D3400CB6409 /* LocationsViewModel.swift in Sources */,
870880222578ED190076BFB1 /* WdtHourSummary.swift in Sources */,
......
//
// WeatherUpdateManager.swift
// OneWeather
//
// Created by Steven G Pint on 9/28/15.
// Copyright © 2015 OneLouder, Inc. All rights reserved.
//
import Foundation
import UserNotifications
class WeatherUpdateManager: NSObject {
static let shared = WeatherUpdateManager()
var allLocationsCount: Int {
return allWdtLocations?.count ?? 0
}
// set private var so we don't have to access disk all the time
private(set) var allWdtLocations: [WdtLocation]?
// Adds the location if it's not a duplicate, makes flurry event, registered for PP notifications, sets this as selected location
// Return true if it added as a new location, false if it didn't add it or it was a dup
func addLocation(_ location: WdtLocation) -> Bool {
print("Add location \(location)")
return true
}
// Deletes the location if found, register/deregister for PP notifications, change selected location to first item if it's the same as deleted location
// Return true if it added as a new location, false if it didn't add it or it was a dup
func deleteLocation(_ location: WdtLocation) -> Bool {
print("Delete location \(location)")
return true
}
var defaultWdtLocation: WdtLocation? {
get {
if let locs = allWdtLocations, locs.first?.myLocation ?? false {
return locs.first
}
return nil
}
}
var selectedWdtLocation: WdtLocation?
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment