Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NSUserDefaults, is a good practice to create local value too?

I'd like to know if creating a mirror of values saved in UserDefault is a good practice or not?

For example if I store parameter "A" in UserDefault is it useful to maintain a copy of this value locally and update it when UserDefault changes?

In my app I had the necessity to frequently read parameter "A", and in this case I think it's better to read from an ivar instead of from a NSUserDefault, but I'm not sure about that so I'm asking if there is a good practice to follow.

like image 317
MatterGoal Avatar asked Aug 08 '11 19:08

MatterGoal


1 Answers

Seems like extra work and a premature optimization to me.

In all my apps I've always retrieved the NSUserDefaults each time they were needed and it was never an issue. Keeps the code short and obvious. And if it becomes a problem, you fix it, easy as that.

like image 86
Nick Veys Avatar answered Oct 15 '22 03:10

Nick Veys