-2

How it can be count in swift? Guess, app launch day can be set with NSUserDefaults, but can't find the right solution..

Yanina
  • 1
  • 3
  • Possible duplicate of [How to tell if an iOS application has been newly installed or updated?](http://stackoverflow.com/questions/8755752/how-to-tell-if-an-ios-application-has-been-newly-installed-or-updated) – NSNoob Dec 17 '15 at 07:12
  • See Andy's answer [here](http://stackoverflow.com/questions/8755752/how-to-tell-if-an-ios-application-has-been-newly-installed-or-updated) and modify it for your use. – NSNoob Dec 17 '15 at 07:12

1 Answers1

0

I would suggest saving the launch time as an NSDate in NSUserDefaults, like you talked about in your question. Apple doesn't provide an official api for calls like this, so you're only option is to implement it yourself.

After retrieving from NSUserDefaults, you can simply call:

NSDate().timeIntervalSinceDate(savedDate)

Which should return the time interval (in seconds) since your app was first launched - you can then format this down to days.

Cailean Wilkinson
  • 1,420
  • 2
  • 19
  • 32