0

I am planning to save users' preference setting in Userdefalut, the problem is the user's preference setting will be edited in View Controller A, and View Controller B and View Controller C need to read it. I understand that I can make an instance like

var userDefaults = UserDefaults.standard

My plan is put it in AppDelegate, so how can I access it from Other View Controller if it is in AppDelegate.

Thanks in advance.

Nan
  • 496
  • 3
  • 21

1 Answers1

1

In general, you do not require to put it in AppDelgate as you're not creating an object every time. Instead, you're using it's shared instance (singleton) so you will always have the same userDefaults objects in all of your view controller.

Hemang
  • 26,840
  • 19
  • 119
  • 186