I am a new programmer and have searched for this answer, but think I might not be using the right terminology.
What I am trying to do is allow the user to use my application, which is a game, only once in a 24 hour period. If they try to play the game earlier than the 24 hour period, I would like an alert that tells them to come back later. I have seen this done for other games that give you “credits”, but can’t seem to find the code.
Any help is appreciated!
Use the
NSDateclass to get the current date ([NSDate date]), and then save this value using theNSUserDefaultsclass. When the app is opened, retrieve the value and then compare the old date with the current date. If it has been a day, don’t do anything. Otherwise, show an alert.