Skip to content

Commit 982cfae

Browse files
committed
deleted some unnecessary stuff
Ready for pull request version of the forecast feature
1 parent 3d94216 commit 982cfae

2 files changed

Lines changed: 2 additions & 133 deletions

File tree

Swift Weather/Base.lproj/Main.storyboard

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
2-
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="6250" systemVersion="14A388a" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" initialViewController="6fQ-Nl-7m6">
2+
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="6250" systemVersion="14B25" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" initialViewController="6fQ-Nl-7m6">
33
<dependencies>
44
<deployment identifier="iOS"/>
55
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="6244"/>

Swift Weather/ViewController.swift

Lines changed: 1 addition & 132 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ class ViewController: UIViewController, CLLocationManagerDelegate {
6161

6262
func updateWeatherInfo(latitude: CLLocationDegrees, longitude: CLLocationDegrees) {
6363
let manager = AFHTTPRequestOperationManager()
64-
//let url = "http://api.openweathermap.org/data/2.5/weather"
64+
6565
let url = "http://api.openweathermap.org/data/2.5/forecast"
6666
println(url)
6767

@@ -122,9 +122,7 @@ class ViewController: UIViewController, CLLocationManagerDelegate {
122122
if let weatherArray = (jsonResult["list"]? as? NSArray) {
123123
for index in 0...4 {
124124
if let perTime = (weatherArray[index] as? NSDictionary) {
125-
println("1")
126125
if let main = (perTime["main"]? as? NSDictionary) {
127-
println("2")
128126
var temp = (main["temp"] as Double)
129127
if (cntry == "US") {
130128
// Convert temperature to Fahrenheit if user is within the US
@@ -138,7 +136,6 @@ class ViewController: UIViewController, CLLocationManagerDelegate {
138136
// FIXED: Is it a bug of Xcode 6? can not set the font size in IB.
139137
//self.temperature.font = UIFont.boldSystemFontOfSize(60)
140138
if (index==1) {
141-
println("im in ")
142139
self.temp1.text = "\(temperature)°"
143140
}
144141
if (index==2) {
@@ -150,15 +147,13 @@ class ViewController: UIViewController, CLLocationManagerDelegate {
150147
if (index==4) {
151148
self.temp4.text = "\(temperature)°"
152149
}
153-
println("sup")
154150
}
155151
var dateFormatter = NSDateFormatter()
156152
dateFormatter.dateFormat = "HH:mm"
157153
if let date = (perTime["dt"]? as? Double) {
158154
let thisDate = NSDate(timeIntervalSince1970: date)
159155
let forecastTime = dateFormatter.stringFromDate(thisDate)
160156
if (index==1) {
161-
println("im in ")
162157
self.time1.text = forecastTime
163158
}
164159
if (index==2) {
@@ -287,132 +282,6 @@ class ViewController: UIViewController, CLLocationManagerDelegate {
287282
}
288283
}
289284

290-
291-
func updateUISuccess2(jsonResult: NSDictionary!) {
292-
self.loading.text = nil
293-
self.loadingIndicator.hidden = true
294-
self.loadingIndicator.stopAnimating()
295-
296-
if let tempResult = ((jsonResult["main"]? as NSDictionary)["temp"] as? Double) {
297-
298-
// If we can get the temperature from JSON correctly, we assume the rest of JSON is correct.
299-
var temperature: Double
300-
if let sys = (jsonResult["sys"]? as? NSDictionary) {
301-
if let country = (sys["country"] as? String) {
302-
if (country == "US") {
303-
// Convert temperature to Fahrenheit if user is within the US
304-
temperature = round(((tempResult - 273.15) * 1.8) + 32)
305-
}
306-
else {
307-
// Otherwise, convert temperature to Celsius
308-
temperature = round(tempResult - 273.15)
309-
}
310-
311-
// Is it a bug of Xcode 6? can not set the font size in IB.
312-
self.temperature.font = UIFont.boldSystemFontOfSize(60)
313-
self.temperature.text = "\(temperature)°"
314-
}
315-
316-
if let name = jsonResult["name"] as? String {
317-
self.location.font = UIFont.boldSystemFontOfSize(25)
318-
self.location.text = name
319-
}
320-
321-
if let weather = jsonResult["weather"]? as? NSArray {
322-
var condition = (weather[0] as NSDictionary)["id"] as Int
323-
var sunrise = sys["sunrise"] as Double
324-
var sunset = sys["sunset"] as Double
325-
326-
var nightTime = false
327-
var now = NSDate().timeIntervalSince1970
328-
// println(nowAsLong)
329-
330-
if (now < sunrise || now > sunset) {
331-
nightTime = true
332-
}
333-
//self.updateWeatherIcon(condition, nightTime: nightTime)
334-
return
335-
}
336-
}
337-
}
338-
self.loading.text = "Weather info is not available!"
339-
}
340-
341-
// Converts a Weather Condition into one of our icons.
342-
// Refer to: http://bugs.openweathermap.org/projects/api/wiki/Weather_Condition_Codes
343-
func updateWeatherIcon2(condition: Int, nightTime: Bool) {
344-
// Thunderstorm
345-
if (condition < 300) {
346-
if nightTime {
347-
self.icon.image = UIImage(named: "tstorm1_night")
348-
} else {
349-
self.icon.image = UIImage(named: "tstorm1")
350-
}
351-
}
352-
// Drizzle
353-
else if (condition < 500) {
354-
self.icon.image = UIImage(named: "light_rain")
355-
}
356-
// Rain / Freezing rain / Shower rain
357-
else if (condition < 600) {
358-
self.icon.image = UIImage(named: "shower3")
359-
}
360-
// Snow
361-
else if (condition < 700) {
362-
self.icon.image = UIImage(named: "snow4")
363-
}
364-
// Fog / Mist / Haze / etc.
365-
else if (condition < 771) {
366-
if nightTime {
367-
self.icon.image = UIImage(named: "fog_night")
368-
} else {
369-
self.icon.image = UIImage(named: "fog")
370-
}
371-
}
372-
// Tornado / Squalls
373-
else if (condition < 800) {
374-
self.icon.image = UIImage(named: "tstorm3")
375-
}
376-
// Sky is clear
377-
else if (condition == 800) {
378-
if (nightTime){
379-
self.icon.image = UIImage(named: "sunny_night") // sunny night?
380-
}
381-
else {
382-
self.icon.image = UIImage(named: "sunny")
383-
}
384-
}
385-
// few / scattered / broken clouds
386-
else if (condition < 804) {
387-
if (nightTime){
388-
self.icon.image = UIImage(named: "cloudy2_night")
389-
}
390-
else{
391-
self.icon.image = UIImage(named: "cloudy2")
392-
}
393-
}
394-
// overcast clouds
395-
else if (condition == 804) {
396-
self.icon.image = UIImage(named: "overcast")
397-
}
398-
// Extreme
399-
else if ((condition >= 900 && condition < 903) || (condition > 904 && condition < 1000)) {
400-
self.icon.image = UIImage(named: "tstorm3")
401-
}
402-
// Cold
403-
else if (condition == 903) {
404-
self.icon.image = UIImage(named: "snow5")
405-
}
406-
// Hot
407-
else if (condition == 904) {
408-
self.icon.image = UIImage(named: "sunny")
409-
}
410-
// Weather condition is not available
411-
else {
412-
self.icon.image = UIImage(named: "dunno")
413-
}
414-
}
415-
416285
/*
417286
iOS 8 Utility
418287
*/

0 commit comments

Comments
 (0)