bindings and guarding against typos in userdefaults keys

  • In my controller I can guard myself against mistyping keys used with
    NSUserDefaults by creating global static variables to hold my
    strings. That way the compiler will catch it if I mistype.

    static NSString * const aiLevel = @"ai_level";
    static NSString * const boardSize = @"boardsize";
    static NSString * const animationDelay = @"animationDelay";
    static NSString * const aiPlayerStarts = @"aiPlayerStarts";

    + (void)initialize
    {
        NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
        [defaults registerDefaults:[NSDictionary
    dictionaryWithObjectsAndKeys:
            @"3",  aiLevel,
            @"8",  boardSize,
            @"0.6", animationDelay,
            @"0",  aiPlayerStarts,
            nil]];
    }

    However. I recently ran into a problem where I mistyped a user
    defaults keys in a value binding. Is there a way to guard against
    that, or do I just have to be careful? This might have been made
    easier if there was a nice way to get IB [0] to list all the
    configured bindings for review. (If there is such an option, I
    haven't found it.)

    [0] I'm still on IB 2 on Tiger

    Stig
    --
    http://blog.brautaset.org
    http://code.brautaset.org
previous month october 2007 next month
MTWTFSS
1 2 3 4 5 6 7
8 9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30 31        
Go to today