Created
January 10, 2013 03:17
-
-
Save aaronpearce/4499138 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
+(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