在条件下移动到下一个屏幕?

时间:2015-09-09 07:27:59

标签: ios swift parsing screen nsxmlparser

我不知道方法是否正确:我通过按下按钮发起了对WebService的SOAP调用。在调用之后,它会使用响应进行解析。现在出现的问题是:如果响应为“OK”,请使用您获得的答案跳到下一个屏幕。 我能怎么做?这段代码如下:

func parser(parser: NSXMLParser, foundCharacters string: String?)
{
    if currentElementName == "ClientQRCodeMobileResult"
    {
        var wsResponse = string!
        var splittiamo = split(wsResponse) {$0 == ";"}
        var firstString: String = splittiamo[0]
        if splittiamo[0] == "OK"
        {
            var tmp = splittiamo[1].toInt()
            var tmpDouble = Double(tmp!)
            var tmpRound = Double(round(1.00*tmpDouble)/100.00)
            // Code HERE for next screen.
        }
    }
}

1 个答案:

答案 0 :(得分:1)

我没有清楚地提出你的问题,所以我在答案中提出假设

    var b =string!

 func parser(parser: NSXMLParser, foundCharacters string: String?)
{
   if firstString == "OK"
    {
        var tmp = splittiamo[1].toInt()
        var tmpDouble = Double(tmp!)
        var tmpRound = Double(round(1.00*tmpDouble)/100.00)
        // Code HERE for next screen.

       b= String(format:"%f", tmpRound)
       self.performSegueWithIdentifier("youridntifierName", sender: self)
    }
   else
    {
     // failure status
    }

}

想要传递数据

override func prepareForSegue(segue: UIStoryboardSegue!, sender: AnyObject!) {
if segue.identifier == "youridntifierName" {

   let yourNextViewCOntroller = segue.destinationViewController as UIViewController
    yourNextViewCOntroller.passString=b
}
你的yourNextViewCOntroller中的

为传递数据创建了一个对象,比如

 var passString:String!

额外reference