Re: n00b cocoa bindings question
Re: n00b cocoa bindings question
- Subject: Re: n00b cocoa bindings question
- From: Jonathon Mah <email@hidden>
- Date: Wed, 9 May 2007 23:14:13 +0930
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