5 // Created by Hori,Masaki on 2015/03/01.
6 // Copyright (c) 2015年 Hori,Masaki. All rights reserved.
9 #import "HMLengTransformer.h"
11 typedef NS_ENUM(NSInteger, LengType) {
18 @implementation HMLengTransformer
21 static dispatch_once_t onceToken;
22 dispatch_once(&onceToken, ^{
23 [NSValueTransformer setValueTransformer:[self new] forName:@"HMLengTransformer"];
26 + (Class)transformedValueClass
28 return [NSString class];
30 + (BOOL)allowsReverseTransformation
35 - (id)transformedValue:(id)value
37 if(![value isKindOfClass:[NSNumber class]]) return nil;
39 NSString *result = nil;
40 LengType leng = [value integerValue];
43 result = NSLocalizedString(@"Short", @"Range, short");
46 result = NSLocalizedString(@"Middle", @"Range, middle");
49 result = NSLocalizedString(@"Long", @"Range, long");
52 result = NSLocalizedString(@"Very Long", @"Range, very long");