NSUserDefaults - storing and retrieving data

后端 未结 4 1315
不思量自难忘°
不思量自难忘° 2020-12-18 11:04

I have some data that\'s been stored using NSUserDefaults in one view and then being displayed in another view. The issue I\'m having is that when the user changes the data

4条回答
  •  清酒与你
    2020-12-18 11:44

    When saving data to NSUserDefaults, it doesnt immediately write to the Persistent Storage. When you save data in NSUserDefaults, make sure you call:

    [[NSUserDefaults standardUserDefaults] synchronize];
    

    This way, the value(s) saved will immediately be written to Storage and each subsequent read from the UserDefaults will yield the updated value.

提交回复
热议问题