Answer the question
In order to leave comments, you need to log in
How to keep an application open counter inside the application?
How to keep a counter of the number of application openings inside the application, to further implement the user's progress based on the number of entrances to the application?
Answer the question
In order to leave comments, you need to log in
NSUserDefaults to help
Update:
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
...
let userDefaults = NSUserDefaults.standardUserDefaults()
if var numberOfLaunches = userDefaults.objectForKey("numberOfLaunches") as? Int {
numberOfLaunches++
userDefaults.setInteger(numberOfLaunches, forKey: "numberOfLaunches")
} else {
let n = 1
userDefaults.setInteger(n, forKey: "numberOfLaunches")
}
print(userDefaults.objectForKey("numberOfLaunches") as! Int)
return true
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question