Search code examples
objective-cmacoscocoabindingcocoa-bindings

Cocoa binding direct access to values


I use Cocoa binding (Shared User Defaults Controller) to bind values and enableness of some interface controls. Is there any possibility to get value of this values? Of course I can get them through defining my controls as outlets and then just get them properties, but it is very difficult because I have a lot of such controls and anywhere I need to access my values I need my NIB instance.


Solution

  • NSUserDefaultsController is just a possibility to bind user preferences directly to the NSUserDefaults via IB. You can always access the assigned values using the NSUserDefaults class. You just need to know the key you used to store the value.

    For example :

    NSUserDefaults* defaults = [NSUserDefaults standardUserDefaults]; 
    return [defaults     boolForKey:bDiffTCRatesAllowedPrefKey];
    

    Hope this helps,

    Flo