ios - How to print the result of an if else statement into a specific text box -
i'm relatively new coder wants try out ios development language "swift". app creating weather app show degrees in celsius , possibly advice if statement comes in. however, encountering issue code not know how solve.
import uikit class viewcontroller: uiviewcontroller { @iboutlet weak var weatherlabel: uilabel! @iboutlet weak var quote: uilabel! override func viewdidload() { super.viewdidload() let apikey = "60e0655f404d7bf1" let url = nsurl(string: "https://api.wunderground.com/api/eb56be2ac82d34b5/geolookup/conditions/forecast/q/canada/toronto.json") let data = nsdata(contentsofurl: url!) { let json = try nsjsonserialization.jsonobjectwithdata(data!, options: .allowfragments) let weather = json["current_observation"]!!["temp_c"] weatherlabel.text = "\(weather!!)" var quote = weather var celsius = 20 if celsius >= quote { print("its cold outside, bring jacket!") }else{ print("its hot outside, remember drink water!") //if weather in celsius on 20 degrees, ("its hot outside, remember drink water!") } } catch { print("error serializing json: \(error)") } // additional setup after loading view, typically nib. } }
does know how can set quote in 1 specific text label , degrees in weatherlabel?
i have error saying can't convert anyobject
int
.
var quote = int(weather) use this.
Comments
Post a Comment