views:

54

answers:

2

I want to detect the very first time my view is displayed. After that, I wan't to forget about it. Where can I set a BOOL to do this?

+4  A: 

Just off the top of my head you could set a static var which keeps track of every time "viewDidLoad" has been called, and the first time it is set the tag on the view to 1. Then you ca test the tag value elsewhere.

ennuikiller
I was thinking a similar strategy but does it have to be a global? It could be a simple ivar that the view controller sets or checks. And the place to do it is viewDidAppear (you can have viewDidLoad without the view being shown).
Adam Eberbach
An ivar may not work if the view is destroyed and re-instantiated. A static variable at the view controller level would work in that case, though.
Joe Ibanez
A: 

If you want to track whether the view has never been displayed before i.e. the first time that that application has been used, then NSUserDefaults is a good place for this.

Abizern