Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is Read Access for NSUserDefaults an "expensive" operation?

The title pretty much sums it up, when reading data stored in the NSUserDefaults for an iphone app, are there any performance considerations that need to be made?

Is there anything I'm misssing, or is reading from NSUserDefaults trivial, and can be abused to a developer's heart desire?

like image 963
Alan Avatar asked Dec 05 '11 01:12

Alan


1 Answers

At runtime, you use an NSUserDefaults object to read the defaults that your application uses from a user’s defaults database. NSUserDefaults caches the information to avoid having to open the user’s defaults database each time you need a default value. The synchronize method, which is automatically invoked at periodic intervals, keeps the in-memory cache in sync with a user’s defaults database.

As far as the documentation says it's pretty safe to use it as long as you avoid calling the synchronize too often. You can read more details about it here.

like image 127
Mihai Fratu Avatar answered Nov 02 '22 06:11

Mihai Fratu