0

This is my Root.plist file:

enter image description here

And this is visual presentation of that bundle: enter image description here

All I need to do is change the value of Latest clean to appropriate date. I do it in code:

let PBOOrdersLatestCleanKey = "PBOOrdersLatestCleanKey" let defaults = [PBOOrdersLatestCleanKey: PBODateFormatter(type: .DateAndTimeSimple).stringFromDate(NSDate())] NSUserDefaults.standardUserDefaults().registerDefaults(defaults) NSUserDefaults.standardUserDefaults().synchronize() 

But it is now working. The settings are still the same. Why?

1 Answer 1

1

The problem is you didn't set the object to the specific key. You just registered the defaults but for undefined key. Just try

NSUserDefaults.standardUserDefaults().setObject(PBODateFormatter(type: .DateAndTimeSimple).stringFromDate(NSDate()), forKey:PBOOrdersLatestCleanKey) NSUserDefaults.standardUserDefaults().synchronize() 

Good luck

Sign up to request clarification or add additional context in comments.

3 Comments

Working. What is the difference?
The problem is you didn't set the object to the specific key. You just registered the defaults but for undefined key.
Kindly mark the answer as solved if it works well. to help others users find the right answer.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.