OSDN Git Service

keyのあたまにapi_があってもなくても良いようにした
authormasakih <masakih@users.sourceforge.jp>
Sun, 16 Feb 2014 02:43:40 +0000 (11:43 +0900)
committermasakih <masakih@users.sourceforge.jp>
Sun, 16 Feb 2014 02:43:40 +0000 (11:43 +0900)
KCD.xcodeproj/project.pbxproj
KCD/HMKCManagedObject.h [new file with mode: 0644]
KCD/HMKCManagedObject.m [new file with mode: 0644]
KCD/HMMasterSTypeCommand.m
KCD/KCD.xcdatamodeld/KCD.xcdatamodel/contents

index 16962a1..fcfc890 100644 (file)
@@ -36,6 +36,7 @@
                F4C1190B18A74DF0005D5B25 /* HMJSONCommand.m in Sources */ = {isa = PBXBuildFile; fileRef = F4C1190A18A74DF0005D5B25 /* HMJSONCommand.m */; };
                F4D2CBC218AD0E1A000EBC59 /* HMMasterSTypeCommand.m in Sources */ = {isa = PBXBuildFile; fileRef = F4D2CBC118AD0E1A000EBC59 /* HMMasterSTypeCommand.m */; };
                F4D2CBC518AE2AE2000EBC59 /* HMCompositCommand.m in Sources */ = {isa = PBXBuildFile; fileRef = F4D2CBC418AE2AE2000EBC59 /* HMCompositCommand.m */; };
+               F4D2CBC818B0555A000EBC59 /* HMKCManagedObject.m in Sources */ = {isa = PBXBuildFile; fileRef = F4D2CBC718B0555A000EBC59 /* HMKCManagedObject.m */; };
 /* End PBXBuildFile section */
 
 /* Begin PBXContainerItemProxy section */
                F4D2CBC118AD0E1A000EBC59 /* HMMasterSTypeCommand.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = HMMasterSTypeCommand.m; sourceTree = "<group>"; };
                F4D2CBC318AE2AE2000EBC59 /* HMCompositCommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HMCompositCommand.h; sourceTree = "<group>"; };
                F4D2CBC418AE2AE2000EBC59 /* HMCompositCommand.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = HMCompositCommand.m; sourceTree = "<group>"; };
+               F4D2CBC618B0555A000EBC59 /* HMKCManagedObject.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HMKCManagedObject.h; sourceTree = "<group>"; };
+               F4D2CBC718B0555A000EBC59 /* HMKCManagedObject.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = HMKCManagedObject.m; sourceTree = "<group>"; };
 /* End PBXFileReference section */
 
 /* Begin PBXFrameworksBuildPhase section */
                                F4C1190418A71AEA005D5B25 /* HMJSONReciever.m */,
                                F4C1190618A746EB005D5B25 /* HMJSONTracker.h */,
                                F4C1190718A746EB005D5B25 /* HMJSONTracker.m */,
+                               F4D2CBC618B0555A000EBC59 /* HMKCManagedObject.h */,
+                               F4D2CBC718B0555A000EBC59 /* HMKCManagedObject.m */,
                                F4D2CBBF18ACE7D7000EBC59 /* Command */,
                                F46F103F18A9B85E0063E503 /* HMJSONNode.h */,
                                F46F104018A9B85E0063E503 /* HMJSONNode.m */,
                                F4C118FB18A67B1C005D5B25 /* CanonicalRequest.m in Sources */,
                                F4BDEB5A187252F30069D0CE /* HMAppDelegate.m in Sources */,
                                F46F104918ABAC910063E503 /* KCD.xcdatamodeld in Sources */,
+                               F4D2CBC818B0555A000EBC59 /* HMKCManagedObject.m in Sources */,
                                F4D2CBC218AD0E1A000EBC59 /* HMMasterSTypeCommand.m in Sources */,
                                F46F104518AA50730063E503 /* HMBroserWindowController.m in Sources */,
                        );
diff --git a/KCD/HMKCManagedObject.h b/KCD/HMKCManagedObject.h
new file mode 100644 (file)
index 0000000..135429c
--- /dev/null
@@ -0,0 +1,13 @@
+//
+//  HMKCManagedObject.h
+//  KCD
+//
+//  Created by Hori,Masaki on 2014/02/16.
+//  Copyright (c) 2014年 Hori,Masaki. All rights reserved.
+//
+
+#import <CoreData/CoreData.h>
+
+@interface HMKCManagedObject : NSManagedObject
+
+@end
diff --git a/KCD/HMKCManagedObject.m b/KCD/HMKCManagedObject.m
new file mode 100644 (file)
index 0000000..5610e09
--- /dev/null
@@ -0,0 +1,35 @@
+//
+//  HMKCManagedObject.m
+//  KCD
+//
+//  Created by Hori,Masaki on 2014/02/16.
+//  Copyright (c) 2014年 Hori,Masaki. All rights reserved.
+//
+
+#import "HMKCManagedObject.h"
+
+#import "HMJSONCommand.h"
+
+
+@implementation HMKCManagedObject
+
+- (id)valueForUndefinedKey:(NSString *)key
+{
+       if([key hasPrefix:@"api_"]) {
+               return [self valueForKey:keyByDeletingPrefix(key)];
+       }
+       
+       return [super valueForUndefinedKey:key];
+}
+
+- (void)setValue:(id)value forUndefinedKey:(NSString *)key
+{
+       if([key hasPrefix:@"api_"]) {
+               [self setValue:value forKey:keyByDeletingPrefix(key)];
+               return;
+       }
+       
+       [super setValue:value forUndefinedKey:key];
+}
+
+@end
index 3a9d33d..536cb01 100644 (file)
@@ -55,9 +55,8 @@
                        object = result[0];
                }
                
-               for(NSString *originalKey in type) {
-                       NSString *key = keyByDeletingPrefix(originalKey);
-                       [object setValue:type[originalKey] forKey:key];
+               for(NSString *key in type) {
+                       [object setValue:type[key] forKey:key];
                }
        }
 }
index a9e3781..5b4a6ad 100644 (file)
@@ -61,7 +61,7 @@
         <attribute name="yomi" attributeType="String" indexed="YES" syncable="YES"/>
         <relationship name="ship" optional="YES" maxCount="1" deletionRule="Nullify" destinationEntity="MasterShip" inverseName="spec" inverseEntity="MasterShip" syncable="YES"/>
     </entity>
-    <entity name="MasterSType" syncable="YES">
+    <entity name="MasterSType" representedClassName="HMKCManagedObject" syncable="YES">
         <attribute name="id" attributeType="Integer 32" indexed="YES" syncable="YES"/>
         <attribute name="kcnt" optional="YES" attributeType="Integer 32" syncable="YES"/>
         <attribute name="name" attributeType="String" indexed="YES" syncable="YES"/>