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?

有帮助吗?

解决方案

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.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top