在我的AppDelegate我檢查,如果已經有登錄的用戶。在iOS應用程序中進行用戶身份驗證後,繼續流動的最佳做法是什麼?
if (userExists) {
// Set my main view as the root view controller.
UINavigationController *navController = [[UINavigationController alloc] init];
MainViewController *mainVC = [[MainViewController alloc] init];
[navController setRootViewController:mainVC animated:YES];
[self.window setRootViewController:navController];
}
如果沒有現有用戶我提出一個登錄界面。
現在,一旦用戶已經登錄,我必須繼續流程,顯示MainViewController
。
我目前在做以下,塊,當用戶認證成功時調用:
UINavigationController *navController = [[UINavigationController alloc] init];
MainViewController *mainVC = [[MainViewController alloc] init];
[navController setRootViewController:wordViewController animated:YES];
UIApplication *application = [UIApplication sharedApplication];
[application.windows.firstObject setRootViewController:navController];
這是一個很好的方式去?由於這是整個iOS應用程序中頻繁重複的模式,因此最常見,最明智的做法是什麼?
的可能重複的[用於故事板登錄屏幕的最佳實踐中,在註銷數據處理結算](http://stackoverflow.com/questions/19962276/best-practices-for-storyboard-login- screen-handling-clearing-of-data-upon-logou) – vokilam