私のアプリケーションには、ウェルカム画面として読み込まれるViewControllerがあります。「実行」をタップすると、別のViewControllerが表示され、ユーザーにアカウントを作成させます。情報が送信されると、プロファイルが表示されます。(これは楽しいテストアプリです)ユーザーが登録し、プロファイルを使用してアプリを終了したときに、再登録を続ける必要がないようにしたいと思います。そのため、アプリの最初の起動を検出し、最初の起動後にWelcomeViewControllerとRegisterViewControllerを削除するためのサポートが必要です。
WelcomeViewController:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
if ([[NSUserDefaults standardUserDefaults] boolForKey:@"hasLaunchedOnce"]) {
ProfileViewController *profileVC = [[ProfileViewController alloc] initWithNibName:nil bundle:nil];
[self presentViewController:profileVC animated:NO completion:nil];
} else {
[[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"hasLaunchedOnce"];
[[NSUserDefaults standardUserDefaults] synchronize];
}
}
RegisterViewController:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
if ([[NSUserDefaults standardUserDefaults] boolForKey:@"hasLaunchedOnce"]) {
ProfileViewController *profileVC = [[ProfileViewController alloc] initWithNibName:nil bundle:nil];
[self presentViewController:profileVC animated:NO completion:nil];
} else {
[[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"hasLaunchedOnce"];
[[NSUserDefaults standardUserDefaults] synchronize];
}
}