Skip to content

Instantly share code, notes, and snippets.

@aaronpearce
Created January 10, 2013 03:17
Show Gist options
  • Save aaronpearce/4499138 to your computer and use it in GitHub Desktop.
Save aaronpearce/4499138 to your computer and use it in GitHub Desktop.
+(void)runCommand:(NSString *)command withParameters:(NSDictionary *)params {
// create class name
command = [[command componentsSeparatedByString:@" "] objectAtIndex:0];
command = [NSString stringWithFormat:@"SYEvent_%@", [command capitalizedString]]; // capitalize
Class class = NSClassFromString(command);
if([class respondsToSelector:@selector(run:)])
[class performSelector:@selector(run:) withObject:params];
}
// checks if class exists for command
+(BOOL)isCommand:(NSString *)command {
// create class name
command = [[command componentsSeparatedByString:@" "] objectAtIndex:0];
command = [NSString stringWithFormat:@"SYEvent_%@", [command capitalizedString]]; // capitalize
Class class = NSClassFromString(command);
if(class)
return YES;
else
return NO;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment