检索生命周期控制器的状态。

时间:2023-01-26 09:06:50

Imagine there is a method in my MVC Controller who can be called multiple time during different time of is life.

假设在我的MVC控制器中有一个方法可以在不同的时间内被调用多次。

Is there a way to retrieve, and print out enventually, in wich state is this Controller ?

是否有一种方法可以检索,并最终打印出来,在wich状态下是这个控制器?

It's maybe a short and/or dumb question, but with this indication it'll be easier to know if this method is called at a wrong or good time.

这可能是一个简短而又愚蠢的问题,但有了这个提示,就更容易知道这种方法是在错误的时间还是在适当的时候被调用。

1 个解决方案

#1


0  

I wrote a blog post about exactly this: managing Application LifeCycle as you move through an App.

我写了一篇关于这一点的博客文章:当你通过一个应用程序时,管理应用程序的生命周期。

I'd suggest you subclass UIViewController with this LifeCycleViewController, and then for every VC in the App subclass the LifeCycleViewController. That way as you move around, in the logs you'll get:

我建议你用这个LifeCycleViewController来定义UIViewController,然后在App子类的每个VC中使用LifeCycleViewController。当你移动的时候,在圆木中你会得到:

'RootView willAppear'

'RootView didLoad'

etc.

等。

#1


0  

I wrote a blog post about exactly this: managing Application LifeCycle as you move through an App.

我写了一篇关于这一点的博客文章:当你通过一个应用程序时,管理应用程序的生命周期。

I'd suggest you subclass UIViewController with this LifeCycleViewController, and then for every VC in the App subclass the LifeCycleViewController. That way as you move around, in the logs you'll get:

我建议你用这个LifeCycleViewController来定义UIViewController,然后在App子类的每个VC中使用LifeCycleViewController。当你移动的时候,在圆木中你会得到:

'RootView willAppear'

'RootView didLoad'

etc.

等。