summaryrefslogtreecommitdiffabout
path: root/pumpkin/NumberTransformer.m
authorMichael Krelin <hacker@klever.net>2012-12-08 21:19:17 (UTC)
committer Michael Krelin <hacker@klever.net>2012-12-11 21:59:29 (UTC)
commit8808689fe340bec6e90ab13dd502292b0579cf1f (patch) (unidiff)
tree45b7c863151341f687b74e40bffcbd7ab5468783 /pumpkin/NumberTransformer.m
parent6e7e413ca364d79673e523c09767c18e7cff1bec (diff)
downloadpumpkin-8808689fe340bec6e90ab13dd502292b0579cf1f.zip
pumpkin-8808689fe340bec6e90ab13dd502292b0579cf1f.tar.gz
pumpkin-8808689fe340bec6e90ab13dd502292b0579cf1f.tar.bz2
initial osx portosx/0.0
Signed-off-by: Michael Krelin <hacker@klever.net>
Diffstat (limited to 'pumpkin/NumberTransformer.m') (more/less context) (ignore whitespace changes)
-rw-r--r--pumpkin/NumberTransformer.m19
1 files changed, 19 insertions, 0 deletions
diff --git a/pumpkin/NumberTransformer.m b/pumpkin/NumberTransformer.m
new file mode 100644
index 0000000..c02cd8b
--- a/dev/null
+++ b/pumpkin/NumberTransformer.m
@@ -0,0 +1,19 @@
1
2#import "NumberTransformer.h"
3
4@implementation NumberTransformer
5
6+(Class)transformedValueClass { return [NSNumber class]; }
7+(BOOL)allowsReverseTransformation { return YES; }
8-(id)transformedValue:(id)value {
9 if(value==nil) return nil;
10 if(![value respondsToSelector:@selector(integerValue)]) return nil;
11 return [NSString stringWithFormat:@"%lu",[value integerValue]];
12}
13-(id)reverseTransformedValue:(id)value {
14 if(value==nil) return nil;
15 if(![value respondsToSelector:@selector(integerValue)]) return nil;
16 return @([value integerValue]);
17}
18
19@end