Im having a ViewController on which on clicking a button, label gets updated. I want is, each time the app opens it should retain its old value. Im able to write every value in NSUserDefault but not getting how to write the value on label before the app loads.
Example:
In first run the label is having the value 5.
In second run the label should contain the same value 5, and if i made any changes that change should be there in third run.
Thanx…
Im having a ViewController on which on clicking a button, label gets updated. I
Share
Here’s how to retrieve a stored value from
NSUserDefaultsand set the value for your label when your ViewController loads:I’m assuming your button is already hooked up to an action something like this that will save the value to the standardUserDefaults when clicked: