I'm trying to make the intro screens for my app - namely the terms of service screen that all users have to agree to the 1st time they download and run the app. obviously, once the users agree, i dont want to show them it again every time they log on the app. what is the best way to go about doing this? I've been reading about NSUserDefaults, but am stuck pretty much after that.
Asked
Active
Viewed 1,052 times
0
-
possible duplicate of [iPhone: How do I detect when an app is launched for the first time?](http://stackoverflow.com/questions/308832/iphone-how-do-i-detect-when-an-app-is-launched-for-the-first-time) – chris Feb 04 '15 at 04:03
-
the other q is in obj-c, which i dont know. – sterling archer Feb 04 '15 at 04:11
2 Answers
3
In your AppDelegate or whichever class needs to check for first-run status:
Bool isFirstRun = !NSUserDefaults.standardUserDefaults().boolForKey("kAppPreviousLaunchKey")
NSUserDefaults.standardUserDefaults().setBool(true, forKey:"kAppPreviousLaunchKey")
if isFirstRun {
// React here
}

Joshua Sullivan
- 1,073
- 8
- 12
2
Play with this piece of code in the AppDelegate Class
let launchedBefore = NSUserDefaults.standardUserDefaults().boolForKey("launchedBefore")
if launchedBefore {
print("Not first launch.")
}
else {
print("First launch, setting NSUserDefault.")
NSUserDefaults.standardUserDefaults().setBool(true, forKey: "launchedBefore")
}

Nati Lara-Diaz
- 2,056
- 16
- 8