【发布时间】:2015-07-06 16:43:49
【问题描述】:
使用 Swift 和 Xcode 6.4,我正在创建一个登录系统。它运作良好。我从网站获取 XML 数据并检查用户是否已登录。
func parser(parser: NSXMLParser, didEndElement elementName: String, namespaceURI: String?, qualifiedName qName: String?) {
if elementName == "isLoggedIn" {
if elementValue == "true" {
success = true
println(success)
println("IS HERE")
self.performSegueWithIdentifier("LoginIsOk", sender: nil)
}else if elementValue == "false"{
success = false
println(success)
}
elementValue = nil
}
}
当我运行 APP 时,“println("IS HERE")" 需要 1 秒。 所以我假设。
self.performSegueWithIdentifier("LoginIsOk", sender: nil)
之后执行。但是显示另一个 ViewController 需要大约 5 秒。
如果我也这样做,但在 UIButton 中,例如,单击它后,它会立即显示第二个 ViewController。
知道为什么 func 解析器需要这么长时间吗?谢谢。
【问题讨论】: