• 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
Re: n00b cocoa bindings question
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: n00b cocoa bindings question


  • Subject: Re: n00b cocoa bindings question
  • From: Luke Evans <email@hidden>
  • Date: Wed, 09 May 2007 13:07:43 -0700
  • Thread-topic: n00b cocoa bindings question

Thanks Jonathon, that was helpful.

At least, it has already highlighted a possible misunderstanding I had ­
that defaults were always represented as strings in essence, even if
manually coerced into other things.  I¹ll try expressing my defaults as the
types I¹m actually interested in, and see if this makes a difference.

Assuming that solves my immediate issue, it still leaves with with the
following thoughts:
1. I need to defend against the fact that somebody could change the
persisted default to a type that would cause this problem (i.e. back to a
string, as in this case).
2. ... and I¹m still left wondering a bit why automatic coercion works to
integers from a string, but doesn¹t go the seemingly small Œextra¹ step to
be capable of producing a boolean (especially given the ŒC¹ style
representation/interpretation of boolean (true if any non-zero value).



On 5/9/07 6:44 AM, "Jonathon Mah" <email@hidden> wrote:

> Hi Luke,
>
> On 2007-05-08, at 09:20, Luke Evans wrote:
>
>> > // "Buffer key presses" boolean preference
>> >         [self bind:@"bufferKeys"
>> >             toObject:userDefCtrl
>> >             withKeyPath:@"values.keyboardBuffering"
>> >             options:[NSDictionary dictionaryWithObject:[NSNumber
>> > numberWithBool:YES] forKey:@"NSContinuouslyUpdatesValue"]
>> >         ];
>> >
>> > // ... snip
>> >
>> > Now, after a bunch of head scratching at the somewhat opaque
>> > runtime error:
>> > ... *** -[NSCFString charValue]: selector not recognized [self =
>> > 0x1e3d8]
>
> That exception shows that the the user defaults controller is reading
> the keyboardBuffering value as a string, and trying to convert it
> into a boolean (by calling -charValue, which is implementation speak
> for calling -boolValue). When you changed your methods to take an
> int, everything is fine because NSString does respond to -intValue.
>
> I don't know why it would be reading the value as a string. Perhaps
> you are registering default defaults and supplying it with a string,
> or perhaps you managed to get a string stored in your preferences
> file. Maybe it has even changed itself to an NSNumber by now (by your
> usage of an int).
>
> If all else fails, you can use [[NSUserDefaults standardUserDefaults]
> boolForKey:@"keyboardBuffering"], and register to receive the
> NSUserDefaultsDidChangeNotification.
>
>
>
> Jonathon Mah
> email@hidden
>
>


_______________________________________________

Cocoa-dev mailing list (email@hidden)

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

References: 
 >Re: n00b cocoa bindings question (From: Jonathon Mah <email@hidden>)

  • Prev by Date: Re: KVO using threads
  • Next by Date: Newbie memory question
  • Previous by thread: Re: n00b cocoa bindings question
  • Next by thread: allow user to select a directory
  • Index(es):
    • Date
    • Thread