Skip to content

Commit

Permalink
[TIMOB-13379] Ensure single arg on iOS
Browse files Browse the repository at this point in the history
  • Loading branch information
ewanharris committed Mar 7, 2018
1 parent 38d6aeb commit 9c9444b
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions iphone/Classes/TiConsole.m
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,16 @@ - (void)log:(NSArray *)args
[self logMessage:args severity:@"info"];
}

- (void)time:(NSArray *)args
- (void)time:(id)label
{
ENSURE_SINGLE_ARG_OR_NIL(label, NSString);
if (label == nil) {
label = @"default";
}

if (!_times) {
_times = [[NSMutableDictionary alloc] init];
}
NSString *label = [args componentsJoinedByString:@""] ?: @"default";
if ([_times objectForKey:label] != nil) {
NSString *logMessage = [NSString stringWithFormat:@"Label \"%@\" already exists", label];
[self logMessage:[logMessage componentsSeparatedByString:@" "] severity:@"warn"];
Expand All @@ -28,9 +32,12 @@ - (void)time:(NSArray *)args
[_times setObject:[NSDate date] forKey:label];
}

- (void)timeEnd:(NSArray *)args
- (void)timeEnd:(id)label
{
NSString *label = [args componentsJoinedByString:@""] ?: @"default";
ENSURE_SINGLE_ARG_OR_NIL(label, NSString);
if (label == nil) {
label = @"default";
}
NSDate *startTime = _times[label];
if (startTime == nil) {
NSString *logMessage = [NSString stringWithFormat:@"Label \"%@\" does not exist", label];
Expand Down

0 comments on commit 9c9444b

Please sign in to comment.