Lefora Free Forum
login join
Loading
644 views

Access preference value

Page 1
1–3
regular - member
54 posts

I have been learning cocoa, reading alot and playing with code as I go. I have created a cocoa-project that kinda has a a sample of all the code I have read and tinkered with. In IB i have created a panel in my mainMenu nib that has a color well and an text size slider that are bound to the NSUserdefault system, which created an instance in the instances panel. The controls work and the values are retained in a pref file.

So back in Xcode, how do I retrieve the textSize value? I found some code:

    NSUserDefaults *preferences = [[NSUserDefaults standardUserDefaults] retain];
   // NSString *file = [[NSBundle mainBundle] pathForResource:@"Defaults" ofType:@"plist"];

   // NSDictionary *dict = [NSDictionary dictionaryWithContentsOfFile:file];
   // [preferences registerDefaults:dict];


Isn't there already an instance created by the nib file or do I need to create a new instance to retrieve the value?

Thank you,
                  Todd

regular - member
54 posts

Oops that code sets default values from  from a file. But I believe the first line is what is relevant. I commented out the irrelevant lines.
I plan on using the default pref file in ~/library/preferences/...


?
288 posts

Hi MadDog

Are you saying you're OK - or are you expecting a reply on this one?

__________________
Page 1
1–3

Locked Topic


You must be a member to post in this forum

Join Now!