Revision: 5046
http://skim-app.svn.sourceforge.net/skim-app/?rev=5046&view=rev
Author: hofman
Date: 2008-12-11 12:33:54 +0000 (Thu, 11 Dec 2008)
Log Message:
-----------
collapse methods to get KVC value for templates
Modified Paths:
--------------
trunk/SKTemplateParser.h
trunk/SKTemplateParser.m
Modified: trunk/SKTemplateParser.h
===================================================================
--- trunk/SKTemplateParser.h 2008-12-10 19:01:36 UTC (rev 5045)
+++ trunk/SKTemplateParser.h 2008-12-11 12:33:54 UTC (rev 5046)
@@ -59,7 +59,6 @@
- (BOOL)isNotEmpty;
-- (id)safeValueForKeyPath:(NSString *)keyPath;
- (id)templateValueForKeyPath:(NSString *)keyPath;
- (NSString *)templateStringValue;
Modified: trunk/SKTemplateParser.m
===================================================================
--- trunk/SKTemplateParser.m 2008-12-10 19:01:36 UTC (rev 5045)
+++ trunk/SKTemplateParser.m 2008-12-11 12:33:54 UTC (rev 5046)
@@ -780,14 +780,9 @@
return YES;
}
-- (id)safeValueForKeyPath:(NSString *)keyPath {
- id value = nil;
- @try{ value = [self valueForKeyPath:keyPath]; }
- @catch (id exception) { value = nil; }
- return value;
-}
-
- (id)templateValueForKeyPath:(NSString *)keyPath {
+ id value = nil;
+ NSString *trailingKeyPath = nil;
unsigned int atIndex = [keyPath rangeOfString:@"@"].location;
if (atIndex != NSNotFound) {
unsigned int dotIndex = [keyPath rangeOfString:@"." options:0
range:NSMakeRange(atIndex + 1, [keyPath length] - atIndex - 1)].location;
@@ -795,11 +790,15 @@
static NSSet *arrayOperators = nil;
if (arrayOperators == nil)
arrayOperators = [[NSSet alloc] initWithObjects:@"@avg",
@"@max", @"@min", @"@sum", @"@distinctUnionOfArrays",
@"@distinctUnionOfObjects", @"@distinctUnionOfSets", @"@unionOfArrays",
@"@unionOfObjects", @"@unionOfSets", nil];
- if ([arrayOperators containsObject:[keyPath
substringWithRange:NSMakeRange(atIndex, dotIndex - atIndex)]] == NO)
- return [[self safeValueForKeyPath:[keyPath
substringToIndex:dotIndex]] templateValueForKeyPath:[keyPath
substringFromIndex:dotIndex + 1]];
+ if ([arrayOperators containsObject:[keyPath
substringWithRange:NSMakeRange(atIndex, dotIndex - atIndex)]] == NO) {
+ trailingKeyPath = [keyPath substringFromIndex:dotIndex + 1];
+ keyPath = [keyPath substringToIndex:dotIndex];
+ }
}
}
- return [self safeValueForKeyPath:keyPath];
+ @try{ value = [self valueForKeyPath:keyPath]; }
+ @catch(id exception) { value = nil; }
+ return trailingKeyPath ? [value templateValueForKeyPath:trailingKeyPath] :
value;
}
- (NSString *)templateStringValue {
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
SF.Net email is Sponsored by MIX09, March 18-20, 2009 in Las Vegas, Nevada.
The future of the web can't happen without you. Join us at MIX09 to help
pave the way to the Next Web now. Learn more and register at
http://ad.doubleclick.net/clk;208669438;13503038;i?http://2009.visitmix.com/
_______________________________________________
Skim-app-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/skim-app-commit