Domanda

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?

È stato utile?

Soluzione

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.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top