tags:

views:

27

answers:

1

My app has a main login/password screen where user enters credentials and submits the info to a web service. Once authenticated, web-service will also tell me what kind of user is loggin in. So user can be type "A", "B" or "C".

Now depending on kind of user I need to load different views (having functionalities) only that particular type of user can use. So I have home screens for "A-HOME" "B-HOME" and "C-HOME" which will then be a Nav Controller or a Tab Controller.

So basically if A logged in - next view loaded should be "A-HOME"

My layman's guess is to load view programmatically. However, I prefer to not do it as you can forget few steps and leak or screw the app. Is there any common design pattern that is used in such cases. The scenario seems pretty regular case to me. Are there any apps with sample code on apple's developer website that does the same thing?

Please give your suggestions. Thanks.

A: 

If the views are "sufficient distinct" use different view controllers for each one, and load the approriate one. You can load the whole thing from a nib if you want, just wire this up in code, after your login procedure, i.e.

-(void) doLogin:(LoginType)loginType
{
  if (loginType == LoginTypeA)
  {
      TypeAViewController *viewController = .... // Load from i.e. "TypeAViewController.nib"
      // Add its view
  }
}
Eiko
when I add a view using [self.view addSubView] the view gets added on top of the existing (login) view - is that right? If so, how can I get rid of the login view? I mean how can I get access to the hierarchy? This is the things thats bothering me where I feel I could leak. Is there a better alternative?
Dev