-2
所以我得從Wunderground天氣API文檔此示例代碼:http://www.wunderground.com/weather/api/d/docs?d=resources/code-samples&MR=1解析GET請求與斯威夫特
我怎樣才能獲得相同的信息(在這種情況下,temp_f和位置)的斯威夫特?
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js"></script>
<script>
jQuery(document).ready(function($) {
$.ajax({
url : "http://api.wunderground.com/api/c1ea49b3e06dc3b3/geolookup/conditions/q/IA/Cedar_Rapids.json",
dataType : "jsonp",
success : function(parsed_json) {
var location = parsed_json['location']['city'];
var temp_f = parsed_json['current_observation']['temp_f'];
alert("Current temperature in " + location + " is: " + temp_f);
}
});
});
</script>
見http://www.raywenderlich.com/82706/working-with-json-in-swift-tutorial – Mitch