Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/114.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
Ios UINavigationController的打印值';s堆栈,每次更改时_Ios_Swift_Uinavigationcontroller - Fatal编程技术网

Ios UINavigationController的打印值';s堆栈,每次更改时

Ios UINavigationController的打印值';s堆栈,每次更改时,ios,swift,uinavigationcontroller,Ios,Swift,Uinavigationcontroller,是否可以在每次变量更改时在控制台中打印变量的值?最方便的方法是什么 编辑: 我想跟踪UINavigationController的控制器堆栈的值,您可以使用didSet属性观察者,例如: var exampleValue: String? { didSet { if let exampleValue = exampleValue { print(exampleValue) } } } 您可以使用didSet属性观察者,例如

是否可以在每次变量更改时在控制台中打印变量的值?最方便的方法是什么

编辑:
我想跟踪UINavigationController的控制器堆栈的值,您可以使用
didSet
属性观察者,例如:

var exampleValue: String? {
    didSet {
        if let exampleValue = exampleValue {
            print(exampleValue)
        }
    }
}

您可以使用
didSet
属性观察者,例如:

var exampleValue: String? {
    didSet {
        if let exampleValue = exampleValue {
            print(exampleValue)
        }
    }
}

要观察UINavigationController堆栈,请使用
UINavigationControllerDelegate

func navigationController(navigationController: UINavigationController, didShowViewController viewController: UIViewController, animated: Bool) {
     // print the stack now.
}

要观察UINavigationController堆栈,请使用
UINavigationControllerDelegate

func navigationController(navigationController: UINavigationController, didShowViewController viewController: UIViewController, animated: Bool) {
     // print the stack now.
}

查看(
willSet
/
didSet
)。@twone如果您对UINavigationController感兴趣,请更新您的问题或开始新的问题。您可以设置代理,然后实施以检查堆栈。查看(
willSet
/
didSet
)@ TWONE如果您对UnavigigCube感兴趣,请更新您的问题或启动一个新的One,您可以设置委托,然后实现检查堆栈。如果我想使用它与导航控制器的堆栈将如何类似?考虑使用一个例子,没有强制展开操作符<代码>!代码>(避免给新的Swift用户带来坏习惯:)。例如,如果我们在上面的示例中设置
exampleValue=nil
,该怎么办?@twone您想用导航控制器的堆栈做什么?@pableiros我想看看当我在我的app@pableiros考虑使用<代码>,如果让或<代码>保护> < /C> >而不是<代码>!无。他们都做了同样的事情,但是<代码>如果让对于将来的重构更为干净和安全(如果删除了这个检查,但是忘记删除力)会怎么样?如果我想用导航控制器的堆栈来使用它,它会是什么样子?考虑使用一个没有强制解包操作符<代码>的例子!代码>(避免给新的Swift用户带来坏习惯:)。例如,如果我们在上面的示例中设置
exampleValue=nil
,该怎么办?@twone您想用导航控制器的堆栈做什么?@pableiros我想看看当我在我的app@pableiros考虑使用<代码>,如果让或<代码>保护> < /C> >而不是<代码>!无。它们都做相同的事情,但是如果let对于将来的重构来说更干净、更安全(即,如果您删除了检查,但忘记了删除强制展开,该怎么办)。