Skip to content

Commit

Permalink
[#233] allow numbers for options of move ops
Browse files Browse the repository at this point in the history
  • Loading branch information
Jigish Patel committed Feb 23, 2013
1 parent e936da7 commit 6350d2b
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions Slate/MoveOperation.m
Expand Up @@ -147,13 +147,19 @@ - (NSArray *)requiredOptions {
return [NSArray arrayWithObjects:OPT_X, OPT_Y, OPT_WIDTH, OPT_HEIGHT, nil];
}

- (void)parseOption:(NSString *)name value:(id)value {
- (void)parseOption:(NSString *)name value:(id)val {
// all options should be strings
if (value == nil) { return; }
if (![value isKindOfClass:[NSString class]]) {
@throw([NSException exceptionWithName:[NSString stringWithFormat:@"Invalid %@", name] reason:[NSString stringWithFormat:@"Invalid %@ '%@'", name, value] userInfo:nil]);
if (val == nil) { return; }
NSString *value = nil;
if ([val isKindOfClass:[NSString class]]) {
value = val;
} else if ([val isKindOfClass:[NSNumber class]]) {
value = [val stringValue];
} else {
@throw([NSException exceptionWithName:[NSString stringWithFormat:@"Invalid %@", name] reason:[NSString stringWithFormat:@"Invalid %@ '%@'", name, val] userInfo:nil]);
return;
}
[[self options] setValue:value forKey:name];
if ([name isEqualToString:OPT_X]) {
[[self topLeft] setX:value];
} else if ([name isEqualToString:OPT_Y]) {
Expand Down

0 comments on commit 6350d2b

Please sign in to comment.