[MacRuby-devel] NSUserDefaults and registerDefaults

Sean Mateus seanlilmateus at googlemail.com
Fri Mar 16 06:32:19 PDT 2012


Hi Erik,

here is an example app Matt wrote:
   save: 
https://github.com/mattetti/LiveTV/blob/master/TVFrancaise/AppDelegate.rb#L249-253
  
 read: https://github.com/mattetti/LiveTV/blob/master/TVFrancaise/AppDelegate.rb#L41-42

I hope this will help you


-- Sean Mateus

On Friday, March 16, 2012 9:59:38 AM UTC+1, Erik Lundqvist wrote:
>
> Hi All,
>
> It's time for my first newbie question :)
> Trying to save some default values for user preferences, but failing 
> pretty hard. I was hoping someone would have successfully used 
> NSUserDefaults registerDefaults, and could point me in the right direction.
>
>     def applicationDidFinishLaunching(a_notification)
>
>         app_defaults = {"wcff.magic_key" => "hello world"}
>
>         NSUserDefaults.standardUserDefaults.registerDefaults(app_defaults)
>
>         NSUserDefaults.standardUserDefaults.synchronize
>
>     end
>
>
> Elsewhere in the code...
>
>
>         @magic_key = NSUserDefaults.standardUserDefaults["wcff.magic_key"]
>
>         puts "magic_key#{@magic_key}"
>
>
> It just prints out "magic_key"...
>
>
> Actually setting a value in standardUserDefaults seems to work fine, like 
> this
>
> NSUserDefaults.standardUserDefaults["wcff.magic_key"] = "hello you"
>
> But I want a default
>
>
> Anyone?
>
>  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-devel/attachments/20120316/403dc5b0/attachment.html>


More information about the MacRuby-devel mailing list