diff options
Diffstat (limited to 'Source/SPExportControllerDelegate.m')
-rw-r--r-- | Source/SPExportControllerDelegate.m | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/Source/SPExportControllerDelegate.m b/Source/SPExportControllerDelegate.m index ef084283..8c273813 100644 --- a/Source/SPExportControllerDelegate.m +++ b/Source/SPExportControllerDelegate.m @@ -112,8 +112,10 @@ - (NSArray *)tokenField:(NSTokenField *)tokenField shouldAddObjects:(NSArray *)tokens atIndex:(NSUInteger)index { NSUInteger i, j; + NSInteger k; NSMutableArray *processedTokens = [NSMutableArray array]; NSCharacterSet *alphanumericSet = [NSCharacterSet alphanumericCharacterSet]; + id groupToken; for (NSString *inputToken in tokens) { @@ -137,6 +139,31 @@ } } + // Check to see whether unprocessed strings can be combined to form tokens + for (i = 1; i < [processedTokens count]; i++) { + + // If this is a token object, skip + if ([[processedTokens objectAtIndex:i] isKindOfClass:[SPExportFileNameTokenObject class]]) { + continue; + } + + for (k = i - 1; k >= 0; k--) { + + // If this is a token object, stop processing + if ([[processedTokens objectAtIndex:k] isKindOfClass:[SPExportFileNameTokenObject class]]) { + break; + } + + // Check whether the group of items make up a token + groupToken = [self tokenObjectForString:[[processedTokens subarrayWithRange:NSMakeRange(k, 1 + i - k)] componentsJoinedByString:@""]]; + if ([groupToken isKindOfClass:[SPExportFileNameTokenObject class]]) { + [processedTokens replaceObjectsInRange:NSMakeRange(k, 1 + i - k) withObjectsFromArray:[NSArray arrayWithObject:groupToken]]; + i = k + 1; + break; + } + } + } + return processedTokens; } |