The best way to implement a login page in iPhone app?
<p>I have been searching the net, and i have found many very good examples on how to create a login page for your iPhone app. However... none of then meets my demands, an since i am new to iPhone development( i know java / c / C++ and objective-c), so the programming itself is not the issue.. The issue is where to put the code and what design patterns to use..</p>

<p>My app is a basic tabbar controller with 3 tabs that could contain navigation controllers, but that is not important.. it is the part before the tabbar controller i am interrested in, namely the need to authenticate the user towards a Lotus Domino Server. I have the authenification code working, so that is not the issue either..</p>

<p>By the way, i am concentrating on IOS5 and using storyboards..</p>

<p>Where do i put the "check if user is still authenticated" code ? The domino server will log the user out after 1 hour, so if the user has the app open(in background) then the code that downloads data will die if the user is not told that the session has expired..</p>

<p>So here is what i would like..</p>

<ol>
<li><p>When the app launches, show the login page. This is working for now with the Login View Controller as initial controller, and a modal segue to the tabbar controller..</p></li>
<li><p>Next time the App is launched(either from background or from new is user has closed it completely), check if username and password is stored in userdefaults, and then just login in background, and if that fails(password has changed or another failure) then show the login view controller again..</p></li>
</ol>

<p>So to sum up, where do i put the "part 2" code ? I have a seperate authenticator class that is using delegates, and i can use this class to perform the authentification, and the it will answer back if all is good.</p>

<p>Do i put this in the AppDelegate code ? If i put it in one of the tabbar viewcontrollers, then there might be an issue with the user having tab2 open when launching after 2 hours, and if the check is in tab1, then tab 2 will fail.. Should i put the code in ALL the tabbar viewcontrollers ? Naaa, that is ugly..</p>

<p>I am leaning towards the AppDelegate(appdidbecomeactive), but can that be used as delegate in my authenticator class ?</p>

<p>That was a bit long, sorry for that, but i needed to explain my problem fully so people would understand what i need..</p>

<p>Thank you for your help.. This is my first post, but this forum is fantastic :)</p>
