Skip to content

Instantly share code, notes, and snippets.

@nickjs
Created November 19, 2008 11:04
Show Gist options
  • Save nickjs/26479 to your computer and use it in GitHub Desktop.
Save nickjs/26479 to your computer and use it in GitHub Desktop.
@implementation LEProfilePresentation : CPDictionary
{
CPString _name @accessors(property=name);
}
+ (id)alloc
{
var object = [CPDictionary alloc];
object.isa = [self class];
object._name = nil;
return object;
}
- (id)initWithProfilePresentation:(LEProfilePresentation)aPresentation
{
self = [[LEProfilePresentation alloc] init];
if(self)
{
if([aPresentation name])
[self setName:[aPresentation name]];
var key = "";
for (key in aPresentation._buckets)
[self setObject:[aPresentation objectForKey:key] forKey:key];
}
return
}
- (id)copy
{
return [[LEProfilePresentation alloc] initWithProfilePresentation:self];
}
- (CPMethodSignature)methodSignatureForSelector:(SEL)selector
{
return 1;
}
- (void)forwardInvocation:(CPInvocation)invocation
{
var sel = [invocation selector];
if([sel hasSuffix:":"])
sel = [sel substringToIndex:[sel length]-1];
if([sel hasPrefix:"set"])
{
sel = [sel substringFromIndex:3];
var x = [sel substringToIndex:1];
x = [x lowercaseString];
sel = x + [sel substringFromIndex:1];
[invocation setTarget:self];
[invocation setSelector:@selector(setObject:forKey:)];
[invocation setArgument:[invocation argumentAtIndex:2] atIndex:2];
[invocation setArgument:sel atIndex:3];
}
else
{
[invocation setTarget:self];
[invocation setSelector:@selector(objectForKey:)];
[invocation setArgument:sel atIndex:2];
}
[invocation invoke];
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment