-3

Wrong ^ Read the post before downvoting or making an edit like this.

I am making a game in which the user can restart their progress from the beginning. This should clear all primitive variables and NSUserDefaults.

Is there a fast and efficient way to do this, other than just calling points = 0, etc.. for every variable I have? The NSUserDefaults is easy enough to clear, but I'm not sure how I should clear everything else. Especially with updating labels and everything, I'd have to set up a few delegates and it's something messy that would be a pain to do.

Is there a way to just restart the app back to how it was when initially downloaded? Kind of like the Reset all content and settings option on iOS Simulator, but programatically

Albert K
  • 25
  • 7
  • @EnricoSusatyo No, I mean is there a way to update labels when clearing NSUserDefaults? As I said in my post I know how to clear NSUserDefaults. I'm asking if there is a way to just completely reset everything and update labels. Kind of like the reset button on the iOS simulator. – Albert K Jun 25 '14 at 03:28
  • What labels are you talking about? If it's the labels in your view controllers, you will have to manually clear them yourself. The app doesn't know how to reset itself unless you tell them how to do that. – Enrico Susatyo Jun 25 '14 at 03:42
  • @EnricoSusatyo Ah okay, yes that's what I meant. I was asking because iOS simulator can clear everything from the app and basically "reinstall" it so it's completely cleared. I was wondering if I can do this programmatically. Thanks. – Albert K Jun 25 '14 at 04:41

1 Answers1

0

There's already an answer here:

NSString *appDomain = [[NSBundle mainBundle] bundleIdentifier];
[[NSUserDefaults standardUserDefaults] removePersistentDomainForName:appDomain];
Community
  • 1
  • 1
Enrico Susatyo
  • 19,372
  • 18
  • 95
  • 156