Skip to content

Instantly share code, notes, and snippets.

@cacaodev
Created September 23, 2008 20:52
Show Gist options
  • Save cacaodev/12402 to your computer and use it in GitHub Desktop.
Save cacaodev/12402 to your computer and use it in GitHub Desktop.
//
// main.j
import <Foundation/Foundation.j>
import <AppKit/AppKit.j>
@implementation CPDictionary (CPKeyValueCoding)
- (id)valueForKey:(CPString)key
{
return [self objectForKey:key];
}
- (void)setValue:(CPString)value forKey:(CPString)key
{
[self setObject:value forKey:key];
}
@end
function main(args, namedArgs)
{
CPLogRegister(CPLogConsole);
var dico = [CPDictionary dictionaryWithObject:@"Dupond" forKey:@"lastname"];
[dico setObject:@"Jean" forKey:@"firstname"];
CPLogConsole([dico description]); // 2 keys
var v = [dico valueForKeyPath:@"lastname"];
CPLogConsole([dico description]); // 1 key
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment