• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
bindings and guarding against typos in userdefaults keys
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bindings and guarding against typos in userdefaults keys


  • Subject: bindings and guarding against typos in userdefaults keys
  • From: Brautaset Stig <email@hidden>
  • Date: Mon, 29 Oct 2007 17:30:38 +0000

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



_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Prev by Date: Re: [Leopard] Debugging GC
  • Next by Date: Re: [NSWorkspace/Leopard] Is it a bug or a feature?
  • Previous by thread: Re: [NSWorkspace/Leopard] Is it a bug or a feature?
  • Next by thread: Any word on developers already designing a new Xcode book ?
  • Index(es):
    • Date
    • Thread