I got stuck with a problem over here. I want to parse text out of an xml file about the weather and send it to a label in the second View Controller. In the first step I do this:
var xml = SWXMLHash.parse(urlContent!)
for elem in xml["data"]["weather"][0]["hourly"][self.indexOfTime]{
self.chanceRain = (elem["chanceofrain"].element!.text!)
}
println(self.chanceRain)
(The above is done with SWXMLHash)
After it runs it prints the value without any problems. So the next step is creating the connection between first & second View Controller:
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
if(segue.identifier == "btnSubmitSegue"){
var svc: viewTwo = segue.destinationViewController as viewTwo
svc.datapassed = "hello " + chanceRain
} }
After running it, the label is "hello". When I run it without hello, so like this it does not display anything. Its kinda weird because the variable chanceRain does print in the log, and "hello" displays in the label but chanceRain doesn't
Is anybody able to help me? If more info is needed please let me know which info/code you need to see.
By the way this isn't all the coding but I'm sure it goes wrong in the code I posted.
No comments:
Post a Comment