5 // Created by Hori,Masaki on 2014/02/16.
6 // Copyright (c) 2014年 Hori,Masaki. All rights reserved.
9 #import "HMKCManagedObject.h"
11 #import "HMJSONCommand.h"
14 @implementation HMKCManagedObject
17 - (BOOL)validateValue:(inout id *)ioValue forKey:(NSString *)inKey error:(out NSError **)outError
20 NSArray *t = @[@"api_enqflg", @"api_aftershipid", @"api_progress",
22 // @"api_next_rate_0", @"api_next_rate_1", @"api_next_rate_2",
23 // @"api_req_shiptype_0", @"api_req_shiptype_1", @"api_req_shiptype_2", @"api_req_shiptype_3", @"api_req_shiptype_4", @"api_req_shiptype_5",
24 // @"api_next_rate_req_0", @"api_next_rate_req_1", @"api_next_rate_req_2",
25 // @"api_link_no_0", @"api_link_no_1",
26 @"api_flagship", @"api_name_id",
27 @"api_comment_id", @"api_nickname_id", @"api_member_id",
28 @"api_flag_0", @"api_flag_1", @"api_flag_2", @"api_flag_3", @"api_flag_4",
29 @"api_flag_5", @"api_flag_6", @"api_flag_7",
31 if([t containsObject:inKey]) {
32 if(![*ioValue isKindOfClass:[NSNumber class]]) {
33 id newValue = @([*ioValue integerValue]);
41 if([*ioValue isKindOfClass:[NSNull class]]) {
49 - (id)valueForUndefinedKey:(NSString *)key
51 if([key isEqualToString:@"description"]) {
52 return [self valueForKey:@"description_"];
54 if([key hasPrefix:@"api_"]) {
55 return [self valueForKey:keyByDeletingPrefix(key)];
58 NSEntityDescription *entity = [self entity];
59 NSLog(@"Entity %@ dose not have key %@", entity.name, key);
62 // return [super valueForUndefinedKey:key];
65 - (void)setValue:(id)value forUndefinedKey:(NSString *)key
67 if([key hasPrefix:@"api_"]) {
68 if([key length] < 5) {
72 [self setValue:value forKey:keyByDeletingPrefix(key)];
75 if([key isEqualToString:@"description"]) {
76 [self setValue:value forKey:@"description_"];
80 NSEntityDescription *entity = [self entity];
81 NSLog(@"Entity %@ dose not have key %@, value class is %@, value is '%@'", entity.name, key, NSStringFromClass([value class]), value);
83 // [super setValue:value forUndefinedKey:key];