The API returns me the next:
{
apparentTemperature = "37.08";
cloudCover = 1;
dewPoint = "31.44";
humidity = "0.8";
icon = cloudy;
ozone = "305.37";
precipIntensity = "0.0023";
precipProbability = "0.06";
precipType = rain;
pressure = "1029.17";
summary = Overcast;
temperature = "37.08";
time = 1450515600;
windBearing = 196;
windSpeed = "2.61";
},
{
apparentTemperature = "39.22";
cloudCover = 1;
dewPoint = "33.13";
humidity = "0.79";
icon = cloudy;
ozone = "304.86";
precipIntensity = "0.0016";
precipProbability = "0.03";
precipType = rain;
pressure = "1029.13";
summary = Overcast;
temperature = "39.22";
time = 1450519200;
windBearing = 203;
windSpeed = "2.76";
},
{
apparentTemperature = "41.17";
cloudCover = 1;
dewPoint = "34.77";
humidity = "0.78";
icon = cloudy;
ozone = "303.99";
precipIntensity = "0.0015";
precipProbability = "0.03";
precipType = rain;
pressure = "1028.96";
summary = Overcast;
temperature = "41.17";
time = 1450522800;
windBearing = 213;
windSpeed = "2.73";
},
{
apparentTemperature = "42.47";
cloudCover = "0.99";
dewPoint = "36.04";
humidity = "0.78";
icon = cloudy;
ozone = "302.97";
precipIntensity = "0.0013";
precipProbability = "0.02";
precipType = rain;
pressure = "1028.82";
summary = Overcast;
temperature = "42.47";
time = 1450526400;
windBearing = 215;
windSpeed = "2.58";
});
icon = "partly-cloudy-day";
summary = "Mostly cloudy starting tomorrow morning.";
};
latitude = "45.745138";
longitude = "21.169898";
offset = 2;
timezone = "Europe/Bucharest";
})
My code is :
import UIKit
import Alamofire
class ViewController: UIViewController {
@IBOutlet weak var textField: UITextField!
@IBOutlet weak var webView: UIWebView!
@IBOutlet weak var textView: UITextView!
@IBAction func searchWeather(sender: UIButton) {
loadData()
}
func loadData() {
let city: String = textField.text!
let api_key: String = "https://api.forecast.io/forecast/b33607b3d2611f604df5def613283a8a/"
Alamofire.request(.GET, "\(api_key)45.745138,21.169898").responseJSON { response in
print("\(response.result.value)")
}
}
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
}
I want to obtain some fields like temperature, humidity and pressure from the JSON response and put them in a UItextView into my App. How can I get only the three fields ?