From 6d3c1950153d9172f249b4cfa87499eeac59e7b5 Mon Sep 17 00:00:00 2001 From: Matthew York Date: Fri, 30 May 2014 15:06:14 -0500 Subject: [PATCH 1/2] - Bumped podspec number --- NSObject-ObjectMap.podspec | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/NSObject-ObjectMap.podspec b/NSObject-ObjectMap.podspec index d953b4b..21fbb30 100644 --- a/NSObject-ObjectMap.podspec +++ b/NSObject-ObjectMap.podspec @@ -1,11 +1,11 @@ Pod::Spec.new do |s| s.name = "NSObject-ObjectMap" - s.version = "2.2" + s.version = "2.3.0" s.summary = "This is a drop-in category of NSObject that makes it easy to initialize custom objects from JSON or XML." s.homepage = "https://github.com/uacaps/NSObject-ObjectMap" s.license = { :type => 'UA', :file => 'LICENSE' } s.author = { "uacaps" => "care@cs.ua.edu" } - s.source = { :git => "https://github.com/uacaps/NSObject-ObjectMap.git", :tag => "2.2" } + s.source = { :git => "https://github.com/uacaps/NSObject-ObjectMap.git", :tag => "v2.3.0" } s.platform = :ios, '5.0' s.source_files = 'NSObject-ObjectMap/*.{h,m}' s.requires_arc = true From f38daa33680871b5ba0dea43a855184734854e8e Mon Sep 17 00:00:00 2001 From: Ben Gordon Date: Mon, 2 Jun 2014 07:57:32 -0500 Subject: [PATCH 2/2] Fixed warnings, removed large commented out code methods --- NSObject-ObjectMap.podspec | 4 +- NSObject-ObjectMap/NSObject+ObjectMap.m | 43 +++---------------- .../ObjectWithSingleObjectsArray.m | 18 +++++++- 3 files changed, 26 insertions(+), 39 deletions(-) diff --git a/NSObject-ObjectMap.podspec b/NSObject-ObjectMap.podspec index 21fbb30..084c31f 100644 --- a/NSObject-ObjectMap.podspec +++ b/NSObject-ObjectMap.podspec @@ -1,11 +1,11 @@ Pod::Spec.new do |s| s.name = "NSObject-ObjectMap" - s.version = "2.3.0" + s.version = "2.3.1" s.summary = "This is a drop-in category of NSObject that makes it easy to initialize custom objects from JSON or XML." s.homepage = "https://github.com/uacaps/NSObject-ObjectMap" s.license = { :type => 'UA', :file => 'LICENSE' } s.author = { "uacaps" => "care@cs.ua.edu" } - s.source = { :git => "https://github.com/uacaps/NSObject-ObjectMap.git", :tag => "v2.3.0" } + s.source = { :git => "https://github.com/uacaps/NSObject-ObjectMap.git", :tag => "v2.3.1" } s.platform = :ios, '5.0' s.source_files = 'NSObject-ObjectMap/*.{h,m}' s.requires_arc = true diff --git a/NSObject-ObjectMap/NSObject+ObjectMap.m b/NSObject-ObjectMap/NSObject+ObjectMap.m index 37cb222..1aa5041 100755 --- a/NSObject-ObjectMap/NSObject+ObjectMap.m +++ b/NSObject-ObjectMap/NSObject+ObjectMap.m @@ -379,50 +379,21 @@ -(NSString *)classOfPropertyNamed:(NSString *)propName { apple docs list plenty of examples of what you get for int "i", long "l", unsigned "I", struct, etc.*/ NSString *typeName = [[NSString alloc] initWithData:[NSData dataWithBytes:(attribute + 1) length:strlen(attribute) - 1] encoding:NSUTF8StringEncoding]; return typeName; - } - else if (attribute[0] == 'T' && attribute[1] == '@' && strlen(attribute) == 2) { + } + else if (attribute[0] == 'T' && attribute[1] == '@' && strlen(attribute) == 2) { // it's an ObjC id type: return @"id"; - } - else if (attribute[0] == 'T' && attribute[1] == '@') { + } + else if (attribute[0] == 'T' && attribute[1] == '@') { // it's another ObjC object type: NSData *data = [NSData dataWithBytes:(attribute + 3) length:strlen(attribute) - 4]; NSString *className = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding]; return className; - } - } - return @""; -} - -/* -static const char * getPropertyType(objc_property_t property) { - const char *attributes = property_getAttributes(property); - char buffer[1 + strlen(attributes)]; - strcpy(buffer, attributes); - char *state = buffer, *attribute; - while ((attribute = strsep(&state, ",")) != NULL) { - if (attribute[0] == 'T' && attribute[1] != '@') { - // it's a C primitive type: - /* - if you want a list of what will be returned for these primitives, search online for - "objective-c" "Property Attribute Description Examples" - apple docs list plenty of examples of what you get for int "i", long "l", unsigned "I", struct, etc. - - return (const char *)[[NSData dataWithBytes:(attribute + 1) length:strlen(attribute) - 1] bytes]; - } - else if (attribute[0] == 'T' && attribute[1] == '@' && strlen(attribute) == 2) { - // it's an ObjC id type: - return "id"; - } - else if (attribute[0] == 'T' && attribute[1] == '@') { - // it's another ObjC object type: - NSData *data = [NSData dataWithBytes:(attribute + 3) length:strlen(attribute) - 4]; - NSString *asdf = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding]; - return (const char *)[[NSData dataWithBytes:(attribute + 3) length:strlen(attribute) - 4] bytes]; } } - return ""; -}*/ + + return @""; +} +(NSArray *)arrayFromJSON:(NSArray *)jsonArray ofObjects:(NSString *)obj { //NSString *filteredObject = [NSString stringWithFormat:@"%@s",obj]; diff --git a/Tests/UnitTestsTests/ObjectWithSingleObjectsArray.m b/Tests/UnitTestsTests/ObjectWithSingleObjectsArray.m index e6d7717..08cc5bf 100644 --- a/Tests/UnitTestsTests/ObjectWithSingleObjectsArray.m +++ b/Tests/UnitTestsTests/ObjectWithSingleObjectsArray.m @@ -10,7 +10,7 @@ @implementation ObjectWithSingleObjectsArray -- (instancetype)init{ +- (instancetype)init { if (self = [super init]) { // Set Property Type [self setValue:@"SingleObject" forKeyPath:@"propertyArrayMap.arrayOfObjects"]; @@ -19,6 +19,22 @@ - (instancetype)init{ return self; } ++ (NSString *)mappedPropertyForPropertyName:(NSString *)propertyName { + if ([propertyName isEqualToString:@"array_of_objects"]) { + return @"arrayOfObjects"; + } + + return nil; +} + ++ (Class)classForArrayProperty:(NSString *)propertyName { + if ([propertyName isEqualToString:@"arrayOfObjects"]) { + return [SingleObject class]; + } + + return nil; +} + + (ObjectWithSingleObjectsArray *)newObjectWithArrayOfSingleObjects { ObjectWithSingleObjectsArray *newObject = [[ObjectWithSingleObjectsArray alloc] init]; newObject.arrayOfObjects = @[[SingleObject newSingleObject],[SingleObject newSingleObject],[SingleObject newSingleObject],[SingleObject newSingleObject],[SingleObject newSingleObject]];