Re: Cocoa-dev Digest, Vol 13, Issue 415

2016-09-29 Thread Graham Cox

> On 30 Sep 2016, at 3:48 AM, Gabriel Zachmann  wrote:
> 
> I was just a little bit hesitant to use the regular ScreenSaverDefaults for 
> those really small pieces of data that change every time,
> because I already use the ScreenSaverDefaults to store quite a bit of other 
> data (that changes only rarely) , in total 15 MB.
> 
> That means the OS has to write all of that data back to disk just because I 
> have changed an integer,
> doesn't it?


Don’t prematurely optimize.

Try it and see. How defaults are implemented is hidden - it may be a disk write 
or it may not, that’s a detail you don’t need to consider. If it turns out it’s 
really slow, and that is a problem, then worry about it. I suspect you won’t 
have to.

—Graham



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: Cocoa-dev Digest, Vol 13, Issue 415

2016-09-29 Thread Gabriel Zachmann
>> 
>> I need to make a few small pieces of data (an integer, a string, ...)
>> persistent across different invocations of my screen saver.
>> 
>> That is, when the screen saver is about to quit, I need to save it,
>> when it gets invoked the next time, I need to load it again.
>> 
>> What is the recommended (and easiest?) way to do that?
> 
> NSUserDefaults

Thanks, I believe I have to use ScreenSaverDefaults, then? because
the documentation for ScreenSaverDefaults says:
"Because screen savers are packaged as bundles and loaded by several different 
applications, it is not possible to use NSUserDefaults to store user 
preferences for them."

I was just a little bit hesitant to use the regular ScreenSaverDefaults for 
those really small pieces of data that change every time,
because I already use the ScreenSaverDefaults to store quite a bit of other 
data (that changes only rarely) , in total 15 MB.

That means the OS has to write all of that data back to disk just because I 
have changed an integer,
doesn't it?

Best regards, 
Gabriel.



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com