1

Anybody can tell me when is the case where Bundle.main.bundleIdentifier will returns nil?

if let domain = Bundle.main.bundleIdentifier {
    UserDefaults.standard.removePersistentDomain(forName: domain)
}

With the code above, there are "random cases" where UserDefault was not cleared so I can only assume that the Bundle.main.bundleIdentifier is nil thus the statement were not executed. This is needed in our app otherwise the app will crash if the "old UserDefault" be use and we received number of crash logs because of this.

Thanks!

SquareBox
  • 823
  • 1
  • 10
  • 22

0 Answers0