ios - Basic Forecast app for iphone -


i building basic weather app iphone, novice in programing, app gives me 1 message instead of showing weather, error message have written default, don't know what's wrong it, here code:

import uikit  class viewcontroller: uiviewcontroller {  @iboutlet var usercity: uitextfield!  @ibaction func findweather(sender: anyobject) {      var url = nsurl(string: "http://www.weather-forecast.com/locations/" + usercity.text + "/forecasts/latest")      if url != nil{          let task = nsurlsession.sharedsession().datataskwithurl(url!, completionhandler: { (data, response, error) -> void in              if error == nil             {                 var urlcontent = nsstring(data: data, encoding: nsutf8stringencoding) nsstring!                  var urlcontentarray = urlcontent.componentsseparatedbystring("<span class=\"phrase\">")                  if urlcontentarray.count > 0 {                      var weatherarray = urlcontentarray[1].componentsseparatedbystring("</span>")                      var weather = weatherarray[0] as! string                      self.resultlabel.text = weather                  }else{                     self.resultlabel.text = "was not able find " + self.usercity.text + "weather. please try again1"                 }                }             else{              }})         resultlabel.text = "was not able find weather " + usercity.text + ". please try again2"      }     else{         resultlabel.text = "was not able find weather" + usercity.text + ". please try again3" 


Comments

Popular posts from this blog

c# - Better 64-bit byte array hash -

webrtc - Which ICE candidate am I using and why? -

php - Zend Framework / Skeleton-Application / Composer install issue -