From 66ff81eed6bcf65f8b353078bb3547110d33379c Mon Sep 17 00:00:00 2001 From: Podoprosvetov Dmitry Date: Fri, 27 Oct 2017 12:29:29 +0300 Subject: [PATCH] fine --- .../Rainy/Rainy.xcodeproj/project.pbxproj | 4 + SwiftStyle/Rainy/Rainy/Constants.swift | 36 +++ .../Rainy/CurrentWeatherViewController.swift | 245 ++++++++---------- .../Rainy/HomeWeatherViewController.swift | 193 ++++++-------- .../Rainy/Rainy/SettingsViewController.swift | 44 ++-- SwiftStyle/Rainy/Rainy/WeatherForecast.swift | 48 ++-- 6 files changed, 284 insertions(+), 286 deletions(-) create mode 100644 SwiftStyle/Rainy/Rainy/Constants.swift diff --git a/SwiftStyle/Rainy/Rainy.xcodeproj/project.pbxproj b/SwiftStyle/Rainy/Rainy.xcodeproj/project.pbxproj index cf71440..3bb7254 100644 --- a/SwiftStyle/Rainy/Rainy.xcodeproj/project.pbxproj +++ b/SwiftStyle/Rainy/Rainy.xcodeproj/project.pbxproj @@ -7,6 +7,7 @@ objects = { /* Begin PBXBuildFile section */ + 025F4DC31FA32DAE00635F83 /* Constants.swift in Sources */ = {isa = PBXBuildFile; fileRef = 025F4DC21FA32DAE00635F83 /* Constants.swift */; }; 7B11FC3E1DB53A6900FA6122 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7B11FC3D1DB53A6900FA6122 /* AppDelegate.swift */; }; 7B11FC401DB53A6900FA6122 /* CurrentWeatherViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7B11FC3F1DB53A6900FA6122 /* CurrentWeatherViewController.swift */; }; 7B11FC421DB53A6900FA6122 /* HomeWeatherViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7B11FC411DB53A6900FA6122 /* HomeWeatherViewController.swift */; }; @@ -22,6 +23,7 @@ /* End PBXBuildFile section */ /* Begin PBXFileReference section */ + 025F4DC21FA32DAE00635F83 /* Constants.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Constants.swift; sourceTree = ""; }; 7B11FC3A1DB53A6900FA6122 /* Rainy.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Rainy.app; sourceTree = BUILT_PRODUCTS_DIR; }; 7B11FC3D1DB53A6900FA6122 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 7B11FC3F1DB53A6900FA6122 /* CurrentWeatherViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CurrentWeatherViewController.swift; sourceTree = ""; }; @@ -77,6 +79,7 @@ 7B11FC3C1DB53A6900FA6122 /* Rainy */ = { isa = PBXGroup; children = ( + 025F4DC21FA32DAE00635F83 /* Constants.swift */, 7B11FC3D1DB53A6900FA6122 /* AppDelegate.swift */, 7B11FC3F1DB53A6900FA6122 /* CurrentWeatherViewController.swift */, 7B11FC411DB53A6900FA6122 /* HomeWeatherViewController.swift */, @@ -249,6 +252,7 @@ 7B11FC3E1DB53A6900FA6122 /* AppDelegate.swift in Sources */, 7B11FC401DB53A6900FA6122 /* CurrentWeatherViewController.swift in Sources */, 7B6469FB1DC643AE00AA44F2 /* SettingsViewController.swift in Sources */, + 025F4DC31FA32DAE00635F83 /* Constants.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/SwiftStyle/Rainy/Rainy/Constants.swift b/SwiftStyle/Rainy/Rainy/Constants.swift new file mode 100644 index 0000000..d3856b9 --- /dev/null +++ b/SwiftStyle/Rainy/Rainy/Constants.swift @@ -0,0 +1,36 @@ +// +// Constants.swift +// Rainy +// +// Created by di on 27.10.2017. +// Copyright © 2017 Kirill Averyanov. All rights reserved. +// + +import Foundation +import UIKit + +struct Resources { + static let weatherURL = "http://api.openweathermap.org/data/2.5/weather" + static let trafficURL = "http://www.mapquestapi.com/traffic/v2/incidents" +} + +let photoResources: [String: UIImage] = [ + "01d":#imageLiteral(resourceName: "sunny"), + "01n":#imageLiteral(resourceName: "moon"), + "02d":#imageLiteral(resourceName: "sunny_clouds"), + "02n":#imageLiteral(resourceName: "moodCloud"), + "03d":#imageLiteral(resourceName: "clouds"), + "03n":#imageLiteral(resourceName: "clouds"), + "04d":#imageLiteral(resourceName: "clouds"), + "04n":#imageLiteral(resourceName: "clouds"), + "09d":#imageLiteral(resourceName: "cloud_rain"), + "09n":#imageLiteral(resourceName: "cloud_rain"), + "10d":#imageLiteral(resourceName: "sunCloudRain"), + "10n":#imageLiteral(resourceName: "moonrain"), + "11d":#imageLiteral(resourceName: "storm"), + "11n":#imageLiteral(resourceName: "storm"), + "13d":#imageLiteral(resourceName: "CloudSnow"), + "13n":#imageLiteral(resourceName: "CloudSnow"), + "50d":#imageLiteral(resourceName: "fog"), + "50n":#imageLiteral(resourceName: "fog") +] diff --git a/SwiftStyle/Rainy/Rainy/CurrentWeatherViewController.swift b/SwiftStyle/Rainy/Rainy/CurrentWeatherViewController.swift index 89abfb3..125245a 100644 --- a/SwiftStyle/Rainy/Rainy/CurrentWeatherViewController.swift +++ b/SwiftStyle/Rainy/Rainy/CurrentWeatherViewController.swift @@ -13,156 +13,137 @@ import SwiftyJSON -struct coords{ - var lat: Double = 0 - var lon: Double = 0 +struct coords { + var lat: Double = 0 + var lon: Double = 0 } class CurrentWeatherViewController: UIViewController, CLLocationManagerDelegate { - @IBOutlet weak var temperatureLabel: UILabel! - @IBOutlet weak var timeLabel: UILabel! - @IBOutlet weak var stateLabel: UILabel! - @IBOutlet weak var windLabel: UILabel! - @IBOutlet weak var cityNameLabel: UILabel! - @IBOutlet weak var imageWeather: UIImageView! - - private var locationManager: CLLocationManager! - // private let constrain: Constants = Constants() - private var currentForecast: WeatherForecast? { - didSet{ - reloadUI() - } + @IBOutlet weak var temperatureLabel: UILabel! + @IBOutlet weak var timeLabel: UILabel! + @IBOutlet weak var stateLabel: UILabel! + @IBOutlet weak var windLabel: UILabel! + @IBOutlet weak var cityNameLabel: UILabel! + @IBOutlet weak var imageWeather: UIImageView! + + private var locationManager: CLLocationManager! + private var currentForecast: WeatherForecast? { + didSet{ + reloadUI() + } + } + + private var myCoords: coords = coords() + + override func viewDidLoad() { + super.viewDidLoad() + locationManager = CLLocationManager() + locationManager.delegate = self + locationManager.desiredAccuracy = kCLLocationAccuracyThreeKilometers + if(CLLocationManager.authorizationStatus() == .notDetermined) { + locationManager.requestWhenInUseAuthorization() } - private let photoResources: [String: UIImage] = [ - "01d":#imageLiteral(resourceName: "sunny"), - "01n":#imageLiteral(resourceName: "moon"), - "02d":#imageLiteral(resourceName: "sunny_clouds"), - "02n":#imageLiteral(resourceName: "moodCloud"), - "03d":#imageLiteral(resourceName: "clouds"), - "03n":#imageLiteral(resourceName: "clouds"), - "04d":#imageLiteral(resourceName: "clouds"), - "04n":#imageLiteral(resourceName: "clouds"), - "09d":#imageLiteral(resourceName: "cloud_rain"), - "09n":#imageLiteral(resourceName: "cloud_rain"), - "10d":#imageLiteral(resourceName: "sunCloudRain"), - "10n":#imageLiteral(resourceName: "moonrain"), - "11d":#imageLiteral(resourceName: "storm"), - "11n":#imageLiteral(resourceName: "storm"), - "13d":#imageLiteral(resourceName: "CloudSnow"), - "13n":#imageLiteral(resourceName: "CloudSnow"), - "50d":#imageLiteral(resourceName: "fog"), - "50n":#imageLiteral(resourceName: "fog")] - - - private var myCoords: coords = coords() - - - override func viewDidLoad() { - super.viewDidLoad() - locationManager = CLLocationManager() - locationManager.delegate = self - locationManager.desiredAccuracy = kCLLocationAccuracyThreeKilometers - if(CLLocationManager.authorizationStatus() == .notDetermined){ - locationManager.requestWhenInUseAuthorization() - } - - if CLLocationManager.locationServicesEnabled(){ - locationManager.startUpdatingLocation() - } - DispatchQueue.main.asyncAfter(deadline: .now() + .seconds(1), execute: { - self.updateCurrentForecast() - }) + if CLLocationManager.locationServicesEnabled(){ + locationManager.startUpdatingLocation() } - - @IBAction func reloadButtonPressed(_ sender: AnyObject) { - if(CLLocationManager.authorizationStatus() == .notDetermined){ - locationManager.requestWhenInUseAuthorization() - } - - if CLLocationManager.locationServicesEnabled(){ - locationManager.startUpdatingLocation() - } - updateCurrentForecast() + DispatchQueue.main.asyncAfter(deadline: .now() + .seconds(1), execute: { + self.updateCurrentForecast() + }) + } + + @IBAction func reloadButtonPressed(_ sender: AnyObject) { + if(CLLocationManager.authorizationStatus() == .notDetermined) { + locationManager.requestWhenInUseAuthorization() } - - internal func locationManager(_ manager: CLLocationManager, - didFailWithError error: Error) { - print("error: ", error) + if CLLocationManager.locationServicesEnabled(){ + locationManager.startUpdatingLocation() } - - internal func locationManager(_ manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) { - self.myCoords.lat = locations[0].coordinate.latitude - self.myCoords.lon = locations[0].coordinate.longitude - locationManager.stopUpdatingLocation() + updateCurrentForecast() + } + + + internal func locationManager(_ manager: CLLocationManager, + didFailWithError error: Error) { + print("error: ", error) + } + + internal func locationManager(_ manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) { + self.myCoords.lat = locations[0].coordinate.latitude + self.myCoords.lon = locations[0].coordinate.longitude + locationManager.stopUpdatingLocation() + } + + + private func updateCurrentForecast(){ + Alamofire.request(Resources.weatherURL, method: .get,parameters: ["lat":myCoords.lat,"lon": myCoords.lon,"APPID": "","units":"metric"],encoding: JSONEncoding.default,headers: nil).responseJSON { response in + + guard response.result.isSuccess else { + return + } + + let json = JSON(response.result.value!) + self.currentForecast = WeatherForecast(currentWeatherTempurature: round(10 * json["main"]["temp"].doubleValue) / 10, + timeStamp: self.getCurrentTime(), + imageName: json["weather"][0]["icon"].string ?? "", + locationCoordinates: (self.myCoords.lat, self.myCoords.lon), + humidity: json["main"]["humidity"].int, + pressure: json["main"]["pressure"].int, + wind: round(10 * json["wind"]["speed"].doubleValue) / 10, cityName: json["name"].string, + stateWeather: json["weather"][0]["description"].string) } - - - private func updateCurrentForecast(){ - Alamofire.request("http://api.openweathermap.org/data/2.5/weather",method: .get,parameters: ["lat":myCoords.lat,"lon": myCoords.lon,"APPID": "","units":"metric"],encoding: JSONEncoding.default,headers: nil).responseJSON{response in - guard response.result.isSuccess else{ - return - } - let json = JSON(response.result.value!) - self.currentForecast = WeatherForecast(currentWeatherTempurature: round(10 * json["main"]["temp"].doubleValue) / 10, - timeStamp: self.getCurrentTime(), - imageName: json["weather"][0]["icon"].string!, - locationCoordinates: (self.myCoords.lat, self.myCoords.lon), - humidity: json["main"]["humidity"].int, - pressure: json["main"]["pressure"].int, - wind: round(10 * json["wind"]["speed"].doubleValue) / 10, cityName: json["name"].string, - stateWeather: json["weather"][0]["description"].string) + } + + private func getTrafficInformation(){ + let parameters = ["boundingBox": "\(myCoords.lat),\(myCoords.lon),\(myCoords.lat - 1),\(myCoords.lon - 1)", "key": ""] + Alamofire.request(Resources.trafficURL, parameters: parameters) + .responseJSON{response in + guard response.result.isSuccess else{ + return } + _ = JSON(response.result.value!) } + } + + private func getCurrentTime() -> String{ + let date = NSDate() + let calendar = NSCalendar.current + var currentTime: String + let components = calendar.dateComponents([.hour, .minute], from: date as Date) + var hour: String = String(describing: components.hour ?? 0) + var minute: String = String(describing: components.minute ?? 0) - private func getTrafficInformation(){ - Alamofire.request("http://www.mapquestapi.com/traffic/v2/incidents", - parameters: ["boundingBox": "\(myCoords.lat),\(myCoords.lon),\(myCoords.lat - 1),\(myCoords.lon - 1)", - "key": ""]) - .responseJSON{response in - guard response.result.isSuccess else{ - return - } - _ = JSON(response.result.value!) - } + if hour.characters.count == 1 { + hour = "0" + hour } - private func getCurrentTime() -> String{ - let date = NSDate() - let calendar = NSCalendar.current - var currentTime: String - let components = calendar.dateComponents([.hour, .minute], from: date as Date!) - var hour: String = String(describing: components.hour!) - var minute: String = String(describing: components.minute!) - if hour.characters.count == 1{ - hour = "0" + hour - } - if(minute.characters.count == 1){ - minute = "0" + minute - } - currentTime = "\(hour):\(minute)" - return currentTime + if(minute.characters.count == 1){ + minute = "0" + minute } - - - private func reloadUI(){ - timeLabel.text = "Updated: \(currentForecast!.timeStamp)" - if let temp = currentForecast?.currentWeatherTempurature{ - temperatureLabel.text = "\(temp)℃" - } - if let city = currentForecast?.cityName{ - cityNameLabel.text = city - } - if let wi = currentForecast?.wind{ - windLabel.text = "\(wi)" - } - if let st = currentForecast?.stateWeather{ - stateLabel.text = st - } - imageWeather.image = photoResources[(currentForecast?.imageName)!] + currentTime = "\(hour):\(minute)" + return currentTime + } + + + + private func reloadUI(){ + timeLabel.text = "Updated: \(currentForecast!.timeStamp)" + if let temp = currentForecast?.currentWeatherTempurature { + temperatureLabel.text = "\(temp)℃" + } + if let city = currentForecast?.cityName { + cityNameLabel.text = city + } + if let wi = currentForecast?.wind { + windLabel.text = "\(wi)" + } + if let st = currentForecast?.stateWeather { + stateLabel.text = st } + imageWeather.image = photoResources[(currentForecast?.imageName)!] + } } diff --git a/SwiftStyle/Rainy/Rainy/HomeWeatherViewController.swift b/SwiftStyle/Rainy/Rainy/HomeWeatherViewController.swift index 046675e..b8e492f 100644 --- a/SwiftStyle/Rainy/Rainy/HomeWeatherViewController.swift +++ b/SwiftStyle/Rainy/Rainy/HomeWeatherViewController.swift @@ -11,121 +11,98 @@ import Alamofire import SwiftyJSON class HomeWeatherViewController: UIViewController { - @IBOutlet weak var timeLabel: UILabel! - @IBOutlet weak var windLabel: UILabel! - @IBOutlet weak var temperatureLabel: UILabel! - @IBOutlet weak var stateLabel: UILabel! - @IBOutlet weak var imageWeatherView: UIImageView! - @IBOutlet weak var cityNameLabel: UILabel! - - private var setts = UserDefaults.standard - private var cityName: String{ - get{ - if let name = setts.value(forKey: "cityName"){ - return name as! String - } - else{ - return "Saint Petersburg" - } - } - }//"Saint Petersburg" -// private let constrain: Constants = Constants() - private var currentForecast: WeatherForecast? { - didSet{ - reloadUI() + @IBOutlet weak var timeLabel: UILabel! + @IBOutlet weak var windLabel: UILabel! + @IBOutlet weak var temperatureLabel: UILabel! + @IBOutlet weak var stateLabel: UILabel! + @IBOutlet weak var imageWeatherView: UIImageView! + @IBOutlet weak var cityNameLabel: UILabel! + + private var setts = UserDefaults.standard + private var cityName: String{ + get{ + if let name = setts.value(forKey: "cityName"){ + return name as! String + } + else{ + return "Saint Petersburg" + } + } + } + + private var currentForecast: WeatherForecast? { + didSet{ + reloadUI() + } + } + + override func viewDidLoad() { + super.viewDidLoad() + updateCurrentForecast() + } + + + @IBAction func refreshButtonPressed(_ sender: Any) { + updateCurrentForecast() + } + + + private func updateCurrentForecast(){ + Alamofire.request(Resources.weatherURL, + parameters: ["q": cityName, + "APPID": "","units":"metric"]) + .responseJSON{response in + guard response.result.isSuccess else { + return } + let json = JSON(response.result.value!) + self.currentForecast = WeatherForecast(currentWeatherTempurature: round(10 * json["main"]["temp"].doubleValue) / 10, + timeStamp: self.getCurrentTime(), + imageName: json["weather"][0]["icon"].string ?? "", + locationCoordinates: (0, 0), + humidity: json["main"]["humidity"].int, + pressure: json["main"]["pressure"].int, + wind: round(10 * json["wind"]["speed"].doubleValue) / 10, cityName: json["name"].string, + stateWeather: json["weather"][0]["description"].string) } - - private let photoResources: [String: UIImage] = [ - "01d":#imageLiteral(resourceName: "sunny"), - "01n":#imageLiteral(resourceName: "moon"), - "02d":#imageLiteral(resourceName: "sunny_clouds"), - "02n":#imageLiteral(resourceName: "moodCloud"), - "03d":#imageLiteral(resourceName: "clouds"), - "03n":#imageLiteral(resourceName: "clouds"), - "04d":#imageLiteral(resourceName: "clouds"), - "04n":#imageLiteral(resourceName: "clouds"), - "09d":#imageLiteral(resourceName: "cloud_rain"), - "09n":#imageLiteral(resourceName: "cloud_rain"), - "10d":#imageLiteral(resourceName: "sunCloudRain"), - "10n":#imageLiteral(resourceName: "moonrain"), - "11d":#imageLiteral(resourceName: "storm"), - "11n":#imageLiteral(resourceName: "storm"), - "13d":#imageLiteral(resourceName: "CloudSnow"), - "13n":#imageLiteral(resourceName: "CloudSnow"), - "50d":#imageLiteral(resourceName: "fog"), - "50n":#imageLiteral(resourceName: "fog") - ] - - - - override func viewDidLoad() { - super.viewDidLoad() - updateCurrentForecast() + } + + private func getCurrentTime() -> String { + let date = NSDate() + let calendar = NSCalendar.current + var currentTime: String + let components = calendar.dateComponents([.hour, .minute], from: date as Date!) + var hour: String = String(describing: components.hour!) + var minute: String = String(describing: components.minute!) + if hour.characters.count == 1{ + hour = "0" + hour } - - - @IBAction func refreshButtonPressed(_ sender: Any) { - updateCurrentForecast() + if(minute.characters.count == 1){ + minute = "0" + minute } - - - private func updateCurrentForecast(){ - Alamofire.request("http://api.openweathermap.org/data/2.5/weather", - parameters: ["q": cityName, - "APPID": "","units":"metric"]) - .responseJSON{response in - guard response.result.isSuccess else{ - return - } - let json = JSON(response.result.value!) - self.currentForecast = WeatherForecast(currentWeatherTempurature: round(10 * json["main"]["temp"].doubleValue) / 10, - timeStamp: self.getCurrentTime(), - imageName: json["weather"][0]["icon"].string!, - locationCoordinates: (0, 0), - humidity: json["main"]["humidity"].int, - pressure: json["main"]["pressure"].int, - wind: round(10 * json["wind"]["speed"].doubleValue) / 10, cityName: json["name"].string, - stateWeather: json["weather"][0]["description"].string) - } + currentTime = "\(hour):\(minute)" + return currentTime + } + + private func reloadUI(){ + timeLabel.text = "Updated: \(currentForecast!.timeStamp)" + if let temp = currentForecast?.currentWeatherTempurature{ + temperatureLabel.text = "\(temp)℃" } - - private func getCurrentTime() -> String{ - let date = NSDate() - let calendar = NSCalendar.current - var currentTime: String - let components = calendar.dateComponents([.hour, .minute], from: date as Date!) - var hour: String = String(describing: components.hour!) - var minute: String = String(describing: components.minute!) - if hour.characters.count == 1{ - hour = "0" + hour - } - if(minute.characters.count == 1){ - minute = "0" + minute - } - currentTime = "\(hour):\(minute)" - return currentTime + if let city = currentForecast?.cityName{ + cityNameLabel.text = city } - - private func reloadUI(){ - timeLabel.text = "Updated: \(currentForecast!.timeStamp)" - if let temp = currentForecast?.currentWeatherTempurature{ - temperatureLabel.text = "\(temp)℃" - } - if let city = currentForecast?.cityName{ - cityNameLabel.text = city - } - if let wi = currentForecast?.wind{ - windLabel.text = "\(wi)" - } - if let st = currentForecast?.stateWeather{ - stateLabel.text = st - } - imageWeatherView.image = photoResources[(currentForecast?.imageName)!] + if let wi = currentForecast?.wind{ + windLabel.text = "\(wi)" + } + if let st = currentForecast?.stateWeather{ + stateLabel.text = st } - - - + imageWeatherView.image = photoResources[(currentForecast?.imageName)!] + } + + + } diff --git a/SwiftStyle/Rainy/Rainy/SettingsViewController.swift b/SwiftStyle/Rainy/Rainy/SettingsViewController.swift index 87461a0..a033027 100644 --- a/SwiftStyle/Rainy/Rainy/SettingsViewController.swift +++ b/SwiftStyle/Rainy/Rainy/SettingsViewController.swift @@ -9,28 +9,28 @@ import UIKit class SettingsViewController: UIViewController { - @IBOutlet weak var textField: UITextField! - @IBOutlet weak var swifthLocation: UISwitch! - - @IBAction func saveButtonPressed(_ sender: Any) { - self.view.endEditing(true) - setts.set(textField.text!, forKey: "cityName") + @IBOutlet weak var textField: UITextField! + @IBOutlet weak var swifthLocation: UISwitch! + + @IBAction func saveButtonPressed(_ sender: Any) { + self.view.endEditing(true) + setts.set(textField.text!, forKey: "cityName") + } + + override func touchesBegan(_ touches: Set, with event: UIEvent?) { + textField.resignFirstResponder() + } + + private var setts = UserDefaults.standard + override func viewDidLoad() { + super.viewDidLoad() + if let name = setts.value(forKey: "cityName"){ + textField.text = String(describing: name) } - - override func touchesBegan(_ touches: Set, with event: UIEvent?) { - textField.resignFirstResponder() + else{ + textField.text = "Saint Petersburg" } - - private var setts = UserDefaults.standard - override func viewDidLoad() { - super.viewDidLoad() - if let name = setts.value(forKey: "cityName"){ - textField.text = String(describing: name) - } - else{ - textField.text = "Saint Petersburg" - } - } - - + } + + } diff --git a/SwiftStyle/Rainy/Rainy/WeatherForecast.swift b/SwiftStyle/Rainy/Rainy/WeatherForecast.swift index 47152bc..3e4c767 100644 --- a/SwiftStyle/Rainy/Rainy/WeatherForecast.swift +++ b/SwiftStyle/Rainy/Rainy/WeatherForecast.swift @@ -10,31 +10,31 @@ import Foundation class WeatherForecast{ - var currentWeatherTempurature: Double? - var timeStamp: String - var imageName: String - var locationCoordinates: (Double, Double)? - var humidity: Int? - var pressure: Int? - var wind: Double? - var cityName: String? - var stateWeather: String? + var currentWeatherTempurature: Double? + var timeStamp: String + var imageName: String + var locationCoordinates: (Double, Double)? + var humidity: Int? + var pressure: Int? + var wind: Double? + var cityName: String? + var stateWeather: String? + + init(currentWeatherTempurature: Double?, + timeStamp: String, imageName: String, + locationCoordinates: (Double, Double)?, humidity: Int?, pressure: Int?, + wind: Double?, cityName: String?, stateWeather: String?) { - init(currentWeatherTempurature: Double?, - timeStamp: String, imageName: String, - locationCoordinates: (Double, Double)?, humidity: Int?, pressure: Int?, - wind: Double?, cityName: String?, stateWeather: String?) { - - self.currentWeatherTempurature = currentWeatherTempurature - self.timeStamp = timeStamp - self.imageName = imageName - self.locationCoordinates = locationCoordinates - self.humidity = humidity - self.pressure = pressure - self.wind = wind - self.cityName = cityName - self.stateWeather = stateWeather - } + self.currentWeatherTempurature = currentWeatherTempurature + self.timeStamp = timeStamp + self.imageName = imageName + self.locationCoordinates = locationCoordinates + self.humidity = humidity + self.pressure = pressure + self.wind = wind + self.cityName = cityName + self.stateWeather = stateWeather + } }