0

This topic is in my mind for a while. Let's say I have a Cocoa app that requires the user to login. Once the user is logged in, the app will show some data taken from the DB. I have two well designed MVCs (LoginModel, LoginView, LoginController & DataModel, DataView, DataController). Which is the best way to redirect to DataController from LoginController? Further more, how could I switch between MVCs if I additionally had Data2Model, Data2View, Data2Controller?

Josue Montano
  • 521
  • 4
  • 16

1 Answers1

0

Create a "credentialed controller" base class that checks for authentication token and automatically launches your Login controller when authentication does not exist.

Your login controller will need a property for the controller to come back to (or if using iOS, you can just pop off the view controller stack).

With this setup, you just use your credentialed controllers and they will automatically display login when credentials expire.

Fruity Geek
  • 7,351
  • 1
  • 32
  • 41
  • Great idea! Thanks. What about a pattern for dealing with multiple windows, panels and tabs? – Josue Montano Apr 15 '13 at 17:06
  • With a multiple window interface, you would probably be safest to implement login as a sheet. The credentialed controller would display the sheet in the primary window (`windowForSheet`) whenever login reauthentication is required. – Fruity Geek Apr 15 '13 at 19:18