diff --git a/NSObject-ObjectMap.podspec b/NSObject-ObjectMap.podspec index d953b4b..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.2" + 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 => "2.2" } + 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]];