ios - Accessing the top view controller from the app delegate -


i need appdelegate able obtain pointer current displayed view controller (have explored visibleviewcontroller navigation views, more generic version better) , read state object instances use in applicationwillresignactive.

my attempt @ had me initializing new objects, , empty. need object's state @ point in runtime.

i figure make singleton class parallels objects, can call on app delegate, seems clunky , wordy. thought of making view controller delegate appdelegate, seems worse.

i know i'm overlooking obvious, must wording search wrong because can't clarity. i've searched stack overflow 10 minutes , skimmed view controller , appdelegate docs.

how can access object's property values @ runtime app delegate?

depending on view controllers , how want app restore state when reopened, appdelegate should have minimal involvement.

instead should consider having view controllers appropriate observe uiapplicationwillresignactivenotification notification , each perform own storage of own state. when app reopens, appdelegate restores root view controller, root vc checks if needs restore anything, , on in chain until data restored. keeps of logic , data storage modular , segregated.

if really:

need object's state @ point in runtime

then have different design problem , need break things down. appdelegate should used specific tasks, has role play in applicationwillresignactive role should not manage 100% of work needs done.


Comments

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -