Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/swift/17.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Swift 执行后的方法是否保证执行标识符?_Swift_Uiviewcontroller_Storyboard_Uikit - Fatal编程技术网

Swift 执行后的方法是否保证执行标识符?

Swift 执行后的方法是否保证执行标识符?,swift,uiviewcontroller,storyboard,uikit,Swift,Uiviewcontroller,Storyboard,Uikit,简单的测试表明performsguewithidentifier之后的方法可以执行,但做出这样的假设安全吗 苹果的文档中没有提到这个话题 例如,下面代码块中的print语句在测试中执行。但是假设你想把一些东西登录到在线分析服务,或者做一些比打印报表更复杂的事情?您是否可以假设performsguewithidentifier之后的语句保证执行,或者应该将这些代码行放在performsguewithidentifier之前 performSegueWithIdentifier(TestSe

简单的测试表明performsguewithidentifier之后的方法可以执行,但做出这样的假设安全吗

苹果的文档中没有提到这个话题

例如,下面代码块中的
print
语句在测试中执行。但是假设你想把一些东西登录到在线分析服务,或者做一些比打印报表更复杂的事情?您是否可以假设performsguewithidentifier之后的语句保证执行,或者应该将这些代码行放在performsguewithidentifier之前

    performSegueWithIdentifier(TestSegue, sender: self)
    print("YO YO YO")
那么

实际上是在您所在的函数中调用的最后一个对象。如果函数中的其他调用没有结束,它将永远不会转换您,直到所有操作都执行为止。例如,假设您有以下代码:

@IBAction func button1Pressed(sender: AnyObject) {


    performSegueWithIdentifier("toIMG", sender: nil)

    let temp = imageViewController()
    temp.printingStuff()
}
imageViewController如下所示:

class imageViewController: UIViewController {

[....]

func printingStuff(){
    while true{
    print("I love pizza")

    }

}
它实际上会一直打印,并且永远不会将您转换到下一个视图。

performSegueWithIdentifier(TestSegue, sender: self)
实际上是在您所在的函数中调用的最后一个对象。如果函数中的其他调用没有结束,它将永远不会转换您,直到所有操作都执行为止。例如,假设您有以下代码:

@IBAction func button1Pressed(sender: AnyObject) {


    performSegueWithIdentifier("toIMG", sender: nil)

    let temp = imageViewController()
    temp.printingStuff()
}
imageViewController如下所示:

class imageViewController: UIViewController {

[....]

func printingStuff(){
    while true{
    print("I love pizza")

    }

}
它实际上会一直打印,并且永远不会将您转换到下一个视图