3

In iOS developing, we can reset an app by uninstalling&reinstalling it, but in macOS developing, I have to find my app's UserDefaults plist and delete it, and run this line to flush the realm db:

try! FileManager.default.removeItem(at:Realm.Configuration.defaultConfiguration.fileURL!)

Is there a more elegant way to do all the things above? Or just a better way to reset the realm db?

F.Flamel
  • 35
  • 4
  • Your question seems ill defined. Where did you "install" it in the first place? Normally you can just delete an application package (directory) in order to get rid of it. During development that should not be necessary since Xcode does the replacement automatically for you. – Patru Jun 29 '17 at 10:21
  • 1
    @Patru I want to delete the user data of my app. Or to be more specific, the data in UserDefaults and database. – F.Flamel Jun 29 '17 at 10:28
  • @F.Flamel have a look at this answer: https://stackoverflow.com/a/12637976/4063602 maybe that helps you in the right direction – pbodsk Jun 29 '17 at 10:50
  • 1
    @Patru I'm sorry but I consider this site as a site for developers. There are some problems which can not be described in code. Such as this one. I am using Realm as my app's database and UserDefaults for some user settings. And each time I want to reset my app, I have to find my app's UserDefaults plist file and delete it then run this line to flush realm db:`try! FileManager.default.removeItem(at: Realm.Configuration.defaultConfiguration.fileURL!)`. I want a more elegant way to do all the things above. – F.Flamel Jun 29 '17 at 11:05
  • @EricAya I'm so sorry this is my first time asking a question on Stackoverflow, I will open a new one. – F.Flamel Jun 29 '17 at 11:48
  • 1
    No no no, you should [edit] this one and improve it; no need to create the same one again. :) – Eric Aya Jun 29 '17 at 11:51
  • @EricAya Thank you very mush! – F.Flamel Jun 29 '17 at 12:36

1 Answers1

2

If you don't mind deleting the files yourself they are located in two different locations:

Hope that helps you.

pbodsk
  • 6,787
  • 3
  • 21
  • 51