Created
April 9, 2017 09:38
-
-
Save shahryarjb/8909b5d88bb4004a6c61e683fc1396f6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// TestViewController.swift | |
// whderjson | |
// | |
// Created by shahryar tavakkoli on 09/04/2017. | |
// Copyright © 2017 shahryar tavakkoli. All rights reserved. | |
// | |
import UIKit | |
import Alamofire | |
class ViewController: UIViewController { | |
var modgz = [ModelWh]() | |
let urlwh = "http://api.openweathermap.org/data/2.5/forecast/daily?lat=37.33233141&lon=-122.0312186&cnt=10&mode=json&appid=42a1771a0b787bf12e734ada0cfc80cb" | |
override func viewDidLoad() { | |
super.viewDidLoad() | |
Alamofire.request(urlwh).responseJSON { response in | |
if let JSON = response.result.value as? Dictionary<String, Any> { | |
if let lists = JSON["list"] as? [Dictionary<String, Any>] { | |
for list in lists { | |
if let kl = list["temp"] as? Dictionary<String, Any> { | |
let day = kl["day"]! | |
let min = kl["min"]! | |
let max = kl["max"]! | |
// start append p1 | |
let p1 = ModelWh(day: "\(day)", min: "\(min)", max: "\(max)" ) | |
self.modgz.append(p1) | |
}// end kl if | |
} // end fore list | |
} // end Lists if | |
}// end if Json | |
completed() | |
} // end of Alamofire | |
//# inja bayad loop for gharar begire test kon bebin chijori misheh | |
for op in self.modgz { | |
print("\(op.max)") | |
} | |
} // end view didload | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment