2 // HMHideEquipNumberTransformer.m
5 // Created by Hori,Masaki on 2015/03/01.
6 // Copyright (c) 2015年 Hori,Masaki. All rights reserved.
9 #import "HMHideEquipNumberTransformer.h"
10 #import "HMServerDataStore.h"
12 #import "HMKCSlotItemObject+Extensions.h"
13 #import "HMKCMasterSlotItemObject.h"
15 static NSArray *showsTypes = nil;
17 @implementation HMHideEquipNumberTransformer
20 static dispatch_once_t onceToken;
21 dispatch_once(&onceToken, ^{
22 [NSValueTransformer setValueTransformer:[self new] forName:@"HMHideEquipNumberTransformer"];
24 showsTypes = @[@6, @7, @8, @9, @10, @11, @25, @26, @41];
28 + (Class)transformedValueClass
30 return [NSString class];
32 + (BOOL)allowsReverseTransformation
37 - (id)transformedValue:(id)value
39 if(![value isKindOfClass:[NSNumber class]]) return nil;
41 NSInteger slotItemID = [value integerValue];
42 if(slotItemID == -1) return @YES;
44 HMServerDataStore *store = [HMServerDataStore defaultManager];
47 NSArray *array = [store objectsWithEntityName:@"SlotItem"
49 predicateFormat:@"id = %@", value];
50 if([array count] == 0) {
51 NSLog(@"SlotItem is invalid.");
54 HMKCSlotItemObject *item = array[0];
56 return @(![showsTypes containsObject:item.master_slotItem.type_2]);