Le 16 juil. 09 à 04:55, Graham Cox a écrit :


On 16/07/2009, at 6:45 AM, Development wrote:

Anyone has some comments or ideas about this? Possibly someone with some inner understanding of how localized strings are read?



Optimise later. You are fretting about the speed of loading strings to the point where you are considering your own look-up scheme - a problem that Cocoa has already solved for you. And all without doing any measurement (presumably - you don't mention any profiling figures).

Here's a fact - *drawing* a string takes aeons compared to the time needed to get that string in place ready to be drawn. So no matter how fast you load the strings, your performance will be graphics/ drawing time bound.

You mention these being error strings - I find it hard to imagine why performance here matters. Are you wishing to display errors at hundreds of frames per second? How is the user expected to read them?

Keep your code simple - use the NSLocalizedString macro or one of the localised string loading methods and worry about performance later if it proves (by actual measurement) necessary.


Again, anyone has thoughts or comments about the inner working of NSUserDefaults?


Same thing. Read from the defaults as needed. As far as I can tell, NSUserDefaults is basically a disk-backed dictionary, and is kept in memory. Access can be assumed to be fast, or at least fast enough, unless actual measurement shows otherwise. As for flushing to disk every time in case of a crash, I'd say don't even if that is Apple's apparent advice [citation needed].

I don't think you will find this citation in the NSUserDefaults doc.

From the -synchronize method:
Discussion
Because this method is automatically invoked at periodic intervals, use this method only if you cannot wait for the automatic synchronization (for example, if your application is about to exit) or if you want to update the user defaults to what is on disk even though you have not made any changes.



And from the CFPreferences User Guide:

The Rule of Thumb on CFPreferences synchronization:

Only synchronize when absolutely 
necessary_______________________________________________

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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

Reply via email to