A ruby abstraction for read/write access to the NSUserDefaults of a Cocoa application. Originally written for a rewrite of the LimeChat preferences code.
LimeChat, the best irc client out there: github.com/psychs/limechat/tree/master My rewrite of the preferences: github.com/alloy/limechat/tree/refactor_preferences
There is also a helper class which assists in making an array of strings accessible via bindings.
See the LimeChat source for a real life example.
class Preferences class Keyword < Namespace defaults_accessor :highlight_enabled, false end # Register the default values with NSUserDefaults.standardUserDefaults. register_default_values! end # Elsewhere preferences.keyword.highlight_enabled # => false preferences.keyword.highlight_enabled? # => false # Setting a new value will save the preference with NSUserDefaults.standardUserDefaults, # which means the setting is in effect in memory and will be synchronized to disk every few minutes, # or by calling preferences.save. preferences.keyword.highlight_enabled = true preferences.keyword.highlight_enabled # => true preferences.keyword.highlight_enabled? # => true
Copyright © <2008> Eloy Duran <firstname.lastname@example.org>
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.